• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

nodejs – react – TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined

开发技术 开发技术 5个月前 (05-12) 291次浏览
首先react需要安装nodejs
然后安装react
https://www.runoob.com/react/react-install.html


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 (D:IDEAworkxlore-utilnode_modulesreact-dev-utilsnoopServiceWorkerMiddleware.js:14:26)
   at Layer.handle [as handle_request] (D:IDEAworkxlore-utilnode_modulesexpresslibrouterlayer.js:95:5)
   at trim_prefix (D:IDEAworkxlore-utilnode_modulesexpresslibrouterindex.js:317:13)
   at D:IDEAworkxlore-utilnode_modulesexpresslibrouterindex.js:284:7
   at Function.process_params (D:IDEAworkxlore-utilnode_modulesexpresslibrouterindex.js:335:12)
   at next (D:IDEAworkxlore-utilnode_modulesexpresslibrouterindex.js:275:10)
   at launchEditorMiddleware (D:IDEAworkxlore-utilnode_modulesreact-dev-utilserrorOverlayMiddleware.js:20:7)
   at Layer.handle [as handle_request] (D:IDEAworkxlore-utilnode_modulesexpresslibrouterlayer.js:95:5)
   at trim_prefix (D:IDEAworkxlore-utilnode_modulesexpresslibrouterindex.js:317:13)
   at D:IDEAworkxlore-utilnode_modulesexpresslibrouterindex.js:284:7
   at Function.process_params (D:IDEAworkxlore-utilnode_modulesexpresslibrouterindex.js:335:12)
   at next (D:IDEAworkxlore-utilnode_modulesexpresslibrouterindex.js:275:10)
   at handleWebpackInternalMiddleware (D:IDEAworkxlore-utilnode_modulesreact-dev-utilsevalSourceMapMiddleware.js:42:7)
   at Layer.handle [as handle_request] (D:IDEAworkxlore-utilnode_modulesexpresslibrouterlayer.js:95:5)

一般是因为版本问题。
我这边的解决办法:

  1. 在package.json中,把”react-scripts”: “^3.3.0″ 替换为”react-scripts”: “^3.4.0”
  2. 删除node_modules文件夹
  3. 执行npm install 或者 yarn install重新安装依赖包(在工程所在文件夹shift + 右键  – 在此处打开命令窗口,然后输入,  或者直接cmd然后cd到所在位置也行)

然后

yarn start
启动

nodejs – react – TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined

原文地址:https://www.cnblogs.com/clamp7724/p/12875523.html


喜欢 (0)