mocha安装错误:意外结束输入

时间:2017-06-24 22:32:25

标签: node.js debugging testing npm mocha

我试图在我的Windows 10上安装mocha但我在终端上收到此错误

$npm install mocha@3.0.0 --save-dev

npm ERR! Unexpected end of input at 1:19983 npm ERR! a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4

npm ERR!

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\NS\AppData\Roaming\npm-cache\_logs\2017-06-24T21_47_36_363Z-debug.log

这是日志文件内容

0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 1 verbose cli 'C:\\Users\\NS\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'install', 1 verbose cli 'mocha@3.0.0', 1 verbose cli '--save-dev' ] 2 info using npm@5.0.2 3 info using node@v6.10.2 4 silly install loadCurrentTree 5 silly install readLocalPackageData 6 http fetch GET 200 https://registry.npmjs.org/mocha 34ms (from cache) 7 silly fetchPackageMetaData error for mocha@3.0.0 Unexpected end of input at 1:19983 7 silly fetchPackageMetaData a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4 7 silly fetchPackageMetaData ^ 8 verbose stack SyntaxError: Unexpected end of input at 1:19983 8 verbose stack a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4 8 verbose stack ^ 8 verbose stack at SyntaxError (native) 8 verbose stack at Object.parseJSON (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\node_modules\jju\lib\parse.js:745:13) 8 verbose stack at parse (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-helpfulerror\index.js:10:13) 8 verbose stack at consumeBody.call.then.buffer (C:\Users\NS\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50) 8 verbose stack at process._tickCallback (internal/process/next_tick.js:109:7) 9 verbose cwd C:\Users\NS\node-test 10 verbose Windows_NT 10.0.15063 11 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\NS\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "mocha@3.0.0" "--save-dev" 12 verbose node v6.10.2 13 verbose npm v5.0.2 14 error Unexpected end of input at 1:19983 14 error a":"./bin/_mocha"},"directories":{},"dist":{"shasum":"653712e9852cce4 14 error ^ 15 verbose exit [ 1, true ]

2 个答案:

答案 0 :(得分:0)

如果您使用的是最新版本的节点

尝试降级到LTS版本

//
sudo npm install n -g
sudo n lts

答案 1 :(得分:0)

如果在本地使用它,则使用命令“ npm cache clean --force ”清除缓存。然后运行您的命令,它将起作用