新安装的软件包,用于更改节点模块

时间:2018-01-01 08:22:29

标签: reactjs npm node-modules

我正在完成一个项目,我对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 npm@5.0.0
 3 info using node@v8.0.0
 4 verbose run-script [ 'prestart', 'start', 'poststart' ]
 5 info lifecycle frontend@0.1.0~prestart: frontend@0.1.0
 6 silly lifecycle frontend@0.1.0~prestart: no script for prestart, continuing
 7 info lifecycle frontend@0.1.0~start: frontend@0.1.0
 8 verbose lifecycle frontend@0.1.0~start: unsafe-perm in lifecycle true
 9 verbose lifecycle frontend@0.1.0~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 frontend@0.1.0~start: CWD: /Users/edper/react/readable-redux/frontend
 11 silly lifecycle frontend@0.1.0~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! frontend@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the frontend@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

1 个答案:

答案 0 :(得分:1)

当您更新Node版本时,某些功能可能已被弃用。每当有主要节点发布时,您应该始终尝试使用它更新所有节点模块。 检查过时的节点模块,您可以使用npm outdated

要解决此问题,您可以删除所有节点模块。

点击npm outdated

使用所有可用的最新模块版本更新您的package.json。

并点击npm install

但请务必检查模块更改日志并查看所有内容已更改。 如果有重大变化,也可能会影响您的应用程序的工作。

相关问题