reactjs npm启动会导致错误elifecycle/3221225477



i刚刚通过命令npm init react-app client安装了反应,并试图通过npm start启动它,但有以下错误。但是在此之前,我已经通过npm install -g create-react-app进行了全球反应,并且正在使用VS代码。

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\Program Files\nodejs\node.exe',
1 verbose cli   'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.9.0
3 info using node@v12.0.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle client@0.1.0~prestart: client@0.1.0
6 info lifecycle client@0.1.0~start: client@0.1.0
7 verbose lifecycle client@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle client@0.1.0~start: PATH: C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;C:Projetoclientnode_modules.bin;C:Program Files (x86)Common FilesOracleJavajavapath;C:ProgramDataOracleJavajavapath;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:WINDOWSSystem32OpenSSH;C:Program FilesMicrosoft SQL ServerClient SDKODBC110ToolsBinn;C:Program Files (x86)Microsoft SQL Server120ToolsBinn;C:Program FilesMicrosoft SQL Server120ToolsBinn;C:Program FilesMicrosoft SQL Server120DTSBinn;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program Filesnodejs;C:UsersleoplAppDataLocalProgramsPythonPython37Scripts;C:UsersleoplAppDataLocalProgramsPythonPython37;C:UsersleoplAppDataLocalMicrosoftWindowsApps;;C:UsersleoplAppDataLocalProgramsMicrosoft VS Codebin;C:UsersleoplAppDataRoamingnpm
9 verbose lifecycle client@0.1.0~start: CWD: C:Projetoclient
10 silly lifecycle client@0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle client@0.1.0~start: Returned: code: 3221225477  signal: null
12 info lifecycle client@0.1.0~start: Failed to exec start script
13 verbose stack Error: client@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 3221225477
13 verbose stack     at EventEmitter.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecycleindex.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:196:13)
13 verbose stack     at ChildProcess.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:196:13)
13 verbose stack     at maybeClose (internal/child_process.js:1000:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:267:5)
14 verbose pkgid client@0.1.0
15 verbose cwd C:Projetoclient
16 verbose Windows_NT 10.0.17763
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
18 verbose node v12.0.0
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 3221225477
22 error client@0.1.0 start: `react-scripts start`
22 error Exit status 3221225477
23 error Failed at the client@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 [ 3221225477, true ]

package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

我尝试过:

  1. 干净的缓存
    • npm cache clean --force
    • delete node_modules文件夹
    • 删除软件包 - 洛克.json文件
    • npm install
  2. 只是删除了一切
    • 删除文件夹中的所有内容
    • 再次使用npm init react-app client安装(但我也尝试过create-react-app client(
  3. 卸载反应并再次安装
    • 删除文件夹中的所有内容
    • npm -g uninstall create-react-app --save
    • 再次安装所有内容
  4. 安装2次(我看到这对一个人有用,所以我也尝试过(
    • npm init react-app client
    • npm install

一个其他信息,但这可能很重要,我无法运行react-scripts start。我无法准确描述VS代码中的错误是什么,因为它在PT-BR中,但它说react-scripts一词尚未识别,并且有CommandNotFoundException错误。

解决了这个问题的简单问题,我正在使用最新版本的node.js(最新-12.0.0(,我卸载了它并安装了10.15.3 lts版本,它是现在很正常。我什至不需要重新安装反应。

您需要做的就是通过使用此命令在全球安装create-react-app

npm install -g create-react-app

之后,您可以使用Create-React-app CLI(命令行接口(,如下所示:

create-react-app <your_app_name>

NPM版本高于5.2,这是快捷方式:

npx create-react-app <your_app_name>

希望这个帮助。

最新更新