执行启动脚本失败 - EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)

xdu*_*ris 7 node.js npm

我已经安装了 node 8.10 并降级到 npm 4,因为我有 npm 5 的错误消息。

*******************************************************************************
ERROR: npm 5 is not supported yet
Run Code Online (Sandbox Code Playgroud)

然后我使用命令降级 npm npm install -g npm@4。

所以我创建了我的项目

$>npm install -g create-react-native-app
$>create-react-native-app AwesomeProject
$>cd AwesomeProject
$>npm start
Run Code Online (Sandbox Code Playgroud)

然后我有以下错误消息。

> AwesomeProject@0.1.0 start /private/var/root/AwesomeProject
> react-native-scripts start

09:42:16: Unable to start server
See https://git.io/v5vcn for more information, either install watchman or run the following snippet:
  sudo sysctl -w kern.maxfiles=5242880
  sudo sysctl -w kern.maxfilesperproc=524288

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! AwesomeProject@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the AwesomeProject@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/root/.npm/_logs/2018-03-23T08_42_16_152Z-debug.log
Run Code Online (Sandbox Code Playgroud)

我看看日志文件

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@4.6.1
3 info using node@v8.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle AwesomeProject@0.1.0~prestart: AwesomeProject@0.1.0
6 silly lifecycle AwesomeProject@0.1.0~prestart: no script for prestart, continuing
7 info lifecycle AwesomeProject@0.1.0~start: AwesomeProject@0.1.0
8 verbose lifecycle AwesomeProject@0.1.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle AwesomeProject@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/private/var/root/AwesomeProject/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
10 verbose lifecycle AwesomeProject@0.1.0~start: CWD: /private/var/root/AwesomeProject
11 silly lifecycle AwesomeProject@0.1.0~start: Args: [ '-c', 'react-native-scripts start' ]
12 silly lifecycle AwesomeProject@0.1.0~start: Returned: code: 1  signal: null
13 info lifecycle AwesomeProject@0.1.0~start: Failed to exec start script
14 verbose stack Error: AwesomeProject@0.1.0 start: `react-native-scripts start`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:126:13)
14 verbose stack     at EventEmitter.emit (events.js:214:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:126:13)
14 verbose stack     at ChildProcess.emit (events.js:214:7)
14 verbose stack     at maybeClose (internal/child_process.js:925:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
15 verbose pkgid AwesomeProject@0.1.0
16 verbose cwd /private/var/root/AwesomeProject
17 verbose Darwin 17.2.0
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 verbose node v8.10.0
20 verbose npm  v4.6.1
21 error code ELIFECYCLE
22 error errno 1
23 error AwesomeProject@0.1.0 start: `react-native-scripts start`
23 error Exit status 1
24 error Failed at the AwesomeProject@0.1.0 start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
Run Code Online (Sandbox Code Playgroud)

你有什么想法吗?

最良好的问候。

lor*_*vcs 6

尝试以下步骤:

  1. npm install -g npm@latest 更新 npm 因为它有时有问题。
  2. rm -rf node_modules 删除现有模块。
  3. npm install 重新安装项目依赖项。

  • 'rm' 是一个 Linux/Unix 命令,用于删除一个或多个文件,'-rf' 设置该命令以递归方式强制运行该命令。如果您收到错误,可能是因为您使用的是 Windows。您可以手动删除该目录或尝试使用“rmdir”。 (2认同)