gpt4 book ai didi

javascript - 为什么 npm react-scripts 在我运行 `npm run start` 时会产生语法错误?

转载 作者:数据小太阳 更新时间:2023-10-29 05:59:47 24 4
gpt4 key购买 nike

<分区>

所以我已经在全栈 React 应用程序上工作了几个月。出于某种原因,当我尝试在命令行上运行 npm run start 时,似乎不知何故,它产生了以下错误;

// npm run start

> pair@0.1.0 start /Users/eden/Documents/GitHub/Pair./pair
> react-scripts start

/Users/eden/Documents/GitHub/Pair./pair/node_modules/react-dev-utils/WebpackDevServerUtils.js:166
compiler.hooks.done.tap('done', async stats => {
^^^^^

SyntaxError: missing ) after argument list
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/eden/Documents/GitHub/Pair./pair/node_modules/react-scripts/scripts/start.js:45:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pair@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pair@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/eden/.npm/_logs/2019-02-11T01_36_36_244Z-debug.log

我尝试了以下方法;

  • 卸载/重新安装节点
  • 卸载/重新安装 npm
  • 确保节点和 npm 是版本 6 或更高
  • 删除 node_modulespackage-lock.json 并重新运行 npm-i
  • 卸载/重新安装 react 脚本
  • 降级 react 脚本
  • 运行 npm install --save react react-dom react-scripts
  • 卸载/重新安装 react-dev-utils

我什至尝试在 GitHub homepage of react-dev-utils 中复制/粘贴 WebpackDevServerUtils.js 的内容到我本地的 node_modules/react-dev-utils/WebpackDevServerUtils.js 来解决语法错误。

我不知道为什么会这样。下面是这次运行的日志;

0 info it worked if it ends with ok
1 verbose cli [ '/Users/eden/.nvm/versions/node/v6.11.2/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'start' ]
2 info using npm@6.4.1
3 info using node@v6.11.2
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle pair@0.1.0~prestart: pair@0.1.0
6 info lifecycle pair@0.1.0~start: pair@0.1.0
7 verbose lifecycle pair@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle pair@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/eden/Documents/GitHub/Pair./pair/node_modules/.bin:/Users/eden/.nvm/versions/node/v6.11.2/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/eden/.rvm/bin
9 verbose lifecycle pair@0.1.0~start: CWD: /Users/eden/Documents/GitHub/Pair./pair
10 silly lifecycle pair@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle pair@0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle pair@0.1.0~start: Failed to exec start script
13 verbose stack Error: pair@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:301:16)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at EventEmitter.emit (events.js:191:7)
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 emitTwo (events.js:106:13)
13 verbose stack at ChildProcess.emit (events.js:191:7)
13 verbose stack at maybeClose (internal/child_process.js:891:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid pair@0.1.0
15 verbose cwd /Users/eden/Documents/GitHub/Pair./pair
16 verbose Darwin 18.2.0
17 verbose argv "/Users/eden/.nvm/versions/node/v6.11.2/bin/node" "/usr/local/bin/npm" "run" "start"
18 verbose node v6.11.2
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error pair@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the pair@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 ]

我查看了 WebpackDevServerUtils.js 的第 166 行,并使用 ESLint 来识别语法错误,但它找不到任何东西。

因此,我的问题是:如何解决这个模糊的错误?

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