我正在完成一个项目,我对React很新。
我试图安装一个名为react-toastify的新软件包,突然之间我正在创建的项目几乎完成了这个错误:
./node_modules/react/index.js
Module build failed: Error: ENOENT: no such file or directory, open
'/Users/mynamehere/react/projectnamehere/frontend/node_modules/react/index.js'
当我检查提到的目录时,文件确实不存在。但这是有效的,因为我在这个项目上工作了很长一段时间。
我尝试使用npm install
重新安装所有内容,但无济于事。
这是我第一次出现错误时从.npm/_logs
获取的初始日志。
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 silly lifecycle [email protected]~prestart: no script for prestart, continuing
7 info lifecycle [email protected]~start: [email protected]
8 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/edper/react/readable-redux/frontend/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/share/dotnet:/usr/local/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
10 verbose lifecycle [email protected]~start: CWD: /Users/edper/react/readable-redux/frontend
11 silly lifecycle [email protected]~start: Args: [ '-c', 'react-scripts start' ]
12 error cb() never called!
13 error This is an error with npm itself. Please report this error at:
14 error <https://github.com/npm/npm/issues>
我尝试按照下面的建议删除node_modules
目录,但是我得到了与上次相同的错误,如下所示:
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
当您更新Node版本时,某些功能可能已被弃用。每当有主要节点发布时,您应该始终尝试使用它更新所有节点模块。要检查过时的节点模块,您可以使用npm outdated
要解决此问题,您可以删除所有节点模块。
打npm outdated
使用所有可用的最新模块版本更新您的package.json。
并击中npm install
但一定要检查模块更改日志并查看所有更改内容。如果有重大更改,它也可能会影响您的应用程序的工作。