开发者问题收集

Reactjs ERR_INVALID_ARG_TYPE

2020-02-18
987

好了! 我从 themeforest 购买了一些模板,预览版一切正常,但使用新版时,我遇到了类似

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

的错误,我相信模板不应该出现此错误,但我仍然遇到了。可能是什么问题?

1个回答

您可以查看此链接 https://github.com/ionic-team/ionic/issues/20503

要解决此问题,只需升级到 "react-scripts": "^3.4.0"

  1. 在您的 package.json 中用 "react-scripts": "^3.4.0" 覆盖现有的 "react-scripts": "^3.x.x"
  2. 删除您的节点模块
  3. 最后在命令提示符中运行 npm installyarn install

我希望它能解决这个问题。

Sifat Haque
2020-02-18