npm 安装错误 Unexpected end of JSON input while parsing near

npm install error Unexpected end of JSON input while parsing near

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   'install',
1 verbose cli   'react-bootstrap',
1 verbose cli   'bootstrap'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.17.0
4 verbose npm-session 4004d1d4d37ac517
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/react-bootstrap 521ms
8 silly fetchPackageMetaData error for react-bootstrap@latest Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
9 http fetch GET 200 https://registry.npmjs.org/bootstrap 521ms
10 silly fetchPackageMetaData error for bootstrap@latest Unexpected end of JSON input while parsing near '...7bc2df7ec608869c9c8",'
11 timing stage:rollbackFailedOptional Completed in 0ms
12 timing stage:runTopLevelLifecycles Completed in 3560ms
13 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
13 verbose stack     at JSON.parse (<anonymous>)
13 verbose stack     at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
13 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
13 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:97:5)
14 verbose cwd D:\Talk2Tutor\material-kit-react-master
15 verbose Windows_NT 10.0.17134
16 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "react-bootstrap" "bootstrap"
17 verbose node v12.17.0
18 verbose npm  v6.14.4
19 error Unexpected end of JSON input while parsing near '...,"requirejs":"~2.1.9"'
20 verbose exit [ 1, true ]

我在 运行 npm i react-bootstrap bootstrap 时遇到上述错误。出现错误后,我尝试了 npm cache clean --force 并没有解决我的问题。然后我 重新安装了 node 并尝试安装依赖项但我仍然收到错误并且安装失败。任何人都修复了这个错误。我尝试了相关问题中提到的所有事情。但这并没有解决我的问题。我使用节点 v12.17.0 和 npm 6.14.4。

Popper.js is required if you're using Bootstrap JS. Check the docs

使用 npm-windows-upgrade 升级 npm 解决了问题。

我尝试通过执行命令 npm cache clean --force 然后执行导致此错误的命令并且它工作正常。

在 运行 命令 npm cache clean --force 之后。您需要删除 package-lock.json 文件。这对我有用。