无法通过 npm install 安装 react-scripts

时间:2021-02-05 11:00:14

标签: reactjs npm npm-install

我是 node 和 react 的新手,我正在尝试使用创建一个 react 应用程序 npx create-react-app 示例 在创建应用程序时,npm 正在尝试安装 react-scripts 模块并且失败并出现以下错误

4967 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\react-scripts\node_modules\watchpack-chokidar2\node_modules\chokidar\node_modules\fsevents):
4968 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
4969 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
4969 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
4969 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
4969 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
4970 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\react-scripts\node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
4971 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
4972 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
4972 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
4972 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
4972 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
4973 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...rollup-1.12.5.tgz","f'
4973 verbose stack     at JSON.parse (<anonymous>)
4973 verbose stack     at parseJson (C:\Software\node-v12.13.1-win-x64\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
4973 verbose stack     at C:\Software\node-v12.13.1-win-x64\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
4973 verbose stack     at runMicrotasks (<anonymous>)
4973 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:93:5)
4974 verbose cwd C:\Personal\Learning\react
4975 verbose Windows_NT 10.0.19042
4976 verbose argv "C:\\Software\\node-v12.13.1-win-x64\\node.exe" "C:\\Software\\node-v12.13.1-win-x64\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "react-scripts"
4977 verbose node v12.13.1
4978 verbose npm  v6.12.1
4979 error Unexpected end of JSON input while parsing near '...rollup-1.12.5.tgz","f'
4980 verbose exit [ 1, true ]

我在谷歌搜索时出错,我找不到解决方案, 我已采取措施解决问题

  1. npm 缓存清理
  2. 尝试全局安装 react-scripts
  3. 删除 npm 配置中的代理并尝试安装

这些都没有效果

1 个答案:

答案 0 :(得分:0)

我建议升级您的 node.js,然后再次尝试 npm install:

npm cache clean -f
npm install -g n
n stable
npm install
相关问题