首页 > 解决方案 > “路径”参数必须是字符串类型。收到未定义。不知道为什么?

问题描述

我正在尝试运行我的反应项目,但我不断收到此错误。我已经重新安装了node和npm,但这个问题仍然存在。想知道下一步该怎么做!

附上,是 package.json,希望它会有所启发。

我从我的 github 存储库中复制了那里的项目,但我仍然收到此错误。

{
  "name": "our-family-client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@blueprintjs/core": "^3.22.3",
    "bootstrap": "^4.3.1",
    "react": "^16.11.0",
    "react-autosuggest": "^9.4.3",
    "react-bootstrap": "^1.0.0-beta.14",
    "react-dom": "^16.11.0",
    "react-grid-gallery": "^0.5.5",
    "react-redux": "^7.1.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^3.4.1",
    "reactstrap": "^8.1.1",
    "redux": "^4.0.4",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "mocha",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^1.13.0",
    "@typescript-eslint/parser": "^1.13.0",
    "chai": "^4.2.0",
    "mocha": "^7.0.0",
    "noop-service-worker-middleware": "^3.0.0"
  }
}


TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:117:11)
    at Object.join (path.js:1039:7)
    at noopServiceWorkerMiddleware (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/react-dev-utils/noopServiceWorkerMiddleware.js:14:26)
    at Layer.handle [as handle_request] (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/index.js:317:13)
    at /Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/index.js:275:10)
    at launchEditorMiddleware (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/react-dev-utils/errorOverlayMiddleware.js:20:7)
    at Layer.handle [as handle_request] (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/index.js:317:13)
    at /Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/index.js:275:10)
    at handleWebpackInternalMiddleware (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/react-dev-utils/evalSourceMapMiddleware.js:42:7)
    at Layer.handle [as handle_request] (/Users/saraginsburg/FlatIron/our-family/our-family-frontend/node_modules/express/lib/router/layer.js:95:5)

标签: node.jsreactjs

解决方案


我在运行节点 10.0 时从 eslint 收到了这个确切的错误

在调查调用堆栈后,我发现一个依赖项使用了仅在 nodejs 10.10 中引入的 nodejs 路径模块参数。我打算打开一个问题,但我检查了 eslint 文档,确实Node.js (^10.12.0, or >=12.0.0)指定了。

我建议你检查你的 Node.js 版本并至少升级到 10.10


推荐阅读