gpt4 book ai didi

node.js - 创建 react 应用程序npm启动错误: Cannot find module '@webassemblyjs/ast'

转载 作者:太空宇宙 更新时间:2023-11-04 01:41:14 25 4
gpt4 key购买 nike

我刚刚开始学习 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 中,我确实有 @webassemblejs/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

最佳答案

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

我现在使用的是 Node 8.12.0 和 npm 6.4.1,并且 npm start 正在运行。

关于node.js - 创建 react 应用程序npm启动错误: Cannot find module '@webassemblyjs/ast' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52841013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com