错误的ERR! JSON输入意外结束

我在前端有一个vuejs的项目,在我与同事的另一个分支合并之后我尝试安装模块但是我收到了这个错误:

npm ERR! Unexpected end of JSON input

该项目工作正常,但问题是我不能使用npm安装或更新等 . 我不知道什么文件是错误 . 我试过了

npm cache clean --force

但仍然是同样的错误 .

这是debug.log的整个错误

0 info it worked if it ends with ok
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 'i' ]
2 info using npm@5.0.3
3 info using node@v8.1.4
4 verbose npm-session 2706d6ef334eddd9
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall company@1.0.0
7 info lifecycle company@1.0.0preinstall: company@1.0.0
8 silly lifecycle company@1.0.0preinstall: no script for preinstall, continuing
9 silly install loadCurrentTree
10 silly install readLocalPackageData
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 silly install loadShrinkwrap
14 verbose stack SyntaxError: Unexpected end of JSON input
14 verbose stack at JSON.parse ()
14 verbose stack at module.exports (C:\Program Files\nodejs\node_modules\npm\lib\utils\parse-json.js:3:15)
14 verbose stack at BB.join (C:\Program Files\nodejs\node_modules\npm\lib\install\read-shrinkwrap.js:31:20)
14 verbose stack at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
14 verbose stack at Holder$3._callFunction (eval at generateHolderClass (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), :14:44)
14 verbose stack at Holder$3.checkFulfillment (eval at generateHolderClass (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:92:16), :29:30)
14 verbose stack at Promise.eval (eval at thenCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\join.js:14:16), :6:20)
14 verbose stack at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:566:21)
14 verbose stack at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
14 verbose stack at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
14 verbose stack at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
14 verbose stack at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:582:21)
14 verbose stack at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
14 verbose stack at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
14 verbose stack at Promise._fulfill (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:638:18)
14 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\nodeback.js:42:21
15 verbose cwd C:\EasyDoSecureAccess
16 verbose Windows_NT 10.0.10586
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "i"
18 verbose node v8.1.4
19 verbose npm v5.0.3
20 error Unexpected end of JSON input
21 verbose exit [ 1, true ]

回答(2)

3 years ago

对于npm修改node_modules树或package.json的任何操作,都会自动生成package-lock.json . 它描述了生成的确切树,以便后续安装能够生成相同的树,而不管中间依赖性更新 .

删除package-lock.json,然后运行 npm install .

然后你可以使用npm安装你想要的任何插件 .

3 years ago

  • npm cache clean --force

  • npm install

如果是假的

  • 删除 package.lock.json