create-react-app npm start错误:找不到模块'@ webassemblyjs / ast'

时间:2018-10-16 17:32:14

标签: node.js reactjs npm

我才刚刚开始学习反应,并且正在关注本教程的第一部分。 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 ]

这是我的ravenous / 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

1 个答案:

答案 0 :(得分:0)

我下载了Node.js的“推荐给大多数用户”版本(当前为8.12.0 LTS)并重新安装了节点。

我现在在节点8.12.0和npm 6.4.1上,并且npm start现在正在工作。