【发布时间】:2018-10-17 02:29:07
【问题描述】:
我刚刚开始学习 React,我正在学习本教程的第一部分。 https://www.codecademy.com/articles/how-to-create-a-react-app
我在终端中运行了以下命令:
npm install -g create-react-app
create-react-app ravenous
# I've also tried npx create-react-app ravenous as per the official React website)
# Both timesI receive a successful output that ends with 'Happy hacking'
cd ravenous
npm start
但我在终端收到以下错误。
npm start
> ravenous@0.1.0 start /Users/sarah/sites/ravenous
> react-scripts start
module.js:559
throw err;
^
Error: Cannot find module '@webassemblyjs/ast'
at Function.Module._resolveFilename (module.js:557:15)
at Function.Module._load (module.js:484:25)
at Module.require (module.js:606:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/sarah/sites/ravenous/node_modules/webpack/lib/wasm/WebAssemblyParser.js:7:11)
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ravenous@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ravenous@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! /Users/sarah/.npm/_logs/2018-10-16T17_12_05_840Z-debug.log
在 node_modules 中,我确实有 @webassemblyjs/ast 文件夹。 debug.log 有这个:
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.6.0
3 info using node@v9.6.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle ravenous@0.1.0~prestart: ravenous@0.1.0
6 info lifecycle ravenous@0.1.0~start: ravenous@0.1.0
7 verbose lifecycle ravenous@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle ravenous@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/s$
9 verbose lifecycle ravenous@0.1.0~start: CWD: /Users/sarah/sites/ravenous
10 silly lifecycle ravenous@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle ravenous@0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle ravenous@0.1.0~start: Failed to exec start script
13 verbose stack Error: ravenous@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at EventEmitter.emit (events.js:127:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:127:13)
13 verbose stack at maybeClose (internal/child_process.js:933:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid ravenous@0.1.0
15 verbose cwd /Users/sarah/sites/ravenous
16 verbose Darwin 16.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v9.6.1
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error ravenous@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the ravenous@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
这是我的贪婪/package.json
{
"name": "ravenous",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-scripts": "2.0.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
一旦创建了贪婪的文件夹,我已经检查了文件系统上的文件夹权限,将所有内容设置为读写,然后重试 npm start 但这似乎没有任何区别。
我尝试删除 package-lock.json 和 node_modules 并重新运行 npm install。尽管奇怪的是 package-lock.json 在我这样做时没有重新创建,但这对问题没有帮助。
我使用的是 Mac OS Sierra 10.12.6
npm -v 给我5.6.0
node -v 给我9.6.1
【问题讨论】:
-
你在运行
cd ravenous之后是否运行npm install? -
@vhflat 绝对不需要这样做
-
是的,我尝试删除 package-lock 和 node_modules 并运行 npm install,但没有帮助。有更新的问题。
-
我认为这可能是
npm的问题。您可以尝试使用yarn安装吗? -
奇怪的是,当我运行
npm install时,没有创建 node_modules 文件夹或 package-lock.json,即使我没有收到错误并且它说“在 15.71 秒内更新了 141 个包”我使用一直使用 npm,通常不会有问题