TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefine

最近学习Gulp4.0将node升级到最新版本。回顾一个旧项目时,npm install安装pakage.json中的依赖文件,启动时出现以下错误

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:375:7)
    at noopServiceWorkerMiddleware (G:\code\React\r-basic\node_modules\react-dev-utils\noopServiceWorkerMiddleware.js:14:26)
    at Layer.handle [as handle_request] (G:\code\React\r-basic\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (G:\code\React\r-basic\node_modules\express\lib\router\index.js:317:13)
    at G:\code\React\r-basic\node_modules\express\lib\router\index.js:284:7
    at Function.process_params (G:\code\React\r-basic\node_modules\express\lib\router\index.js:335:12)
    at next (G:\code\React\r-basic\node_modules\express\lib\router\index.js:275:10)
    at launchEditorMiddleware (G:\code\React\r-basic\node_modules\react-dev-utils\errorOverlayMiddleware.js:20:7)
    at Layer.handle [as handle_request] (G:\code\React\r-basic\node_modules\express\lib\router\layer.js:95:5)

产生的原因:升级了node版本。某些依赖模块是对应不同的node版本

解决方法:

  1. 将node版本降级回原来的版本
  2. 根据package.json将原来安装的依赖模块全部卸载,再重新安装一遍(安装时不要携带模块的版本号)

    // 例如
    npm uni axios redux
    npm i axios redux -D

你可能感兴趣的:(React)