在学习nodejs时,用命令行工具执行npm install xxx,经常卡住或失败,因此想利用第三方模块nrm提高下载速度。 问题:命令行工具执行npm install nrm时,卡住或报错Unexpected end of JSON input while parsing near… 解决:参考前辈的解决思路,成功解决了该问题。
(1)npm install --registry=https://registry.npm.taobao.org --loglevel=silly (2) npm cache clean --force (3) npm install
PS G:\Web\程序\3-code\gulp-demo> npm install --registry=https://registry.npm.taobao.org --loglevel=silly npm info it worked if it ends with ok npm verb cli [ npm verb cli 'C:\\Program Files\\nodejs\\node.exe', npm verb cli 'C:\\Users\\Anne\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js', npm verb cli 'install', npm verb cli '--registry=https://registry.npm.taobao.org', npm verb cli '--loglevel=silly' npm verb cli ] npm info using npm@6.14.8 npm info using node@v12.16.2 npm verb npm-session 40964fe4deed08af npm sill install runPreinstallTopLevelLifecycles npm sill install loadCurrentTree npm sill install readLocalPackageData npm timing stage:loadCurrentTree Completed in 24ms npm sill install loadIdealTree npm sill install cloneCurrentTreeToIdealTree npm timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms npm sill install loadShrinkwrap npm timing stage:loadIdealTree:loadShrinkwrap Completed in 5ms npm sill install loadAllDepsIntoIdealTree npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 8ms npm timing stage:loadIdealTree Completed in 24ms npm sill currentTree gulp-demo npm sill idealTree gulp-demo npm sill install generateActionsToTake npm timing stage:generateActionsToTake Completed in 11ms npm sill diffTrees action count 0 npm sill decomposeActions action count 0 npm sill install executeActions npm sill doSerial global-install 0 npm verb correctMkdir C:\Users\Anne\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing npm verb makeCacheDir UID & GID are irrelevant on win32 npm verb lock using C:\Users\Anne\AppData\Roaming\npm-cache\_locks\staging-75615effd37d994b.lock for G:\Web\程序\3-code\gulp-demo\node_modules\.staging npm sill doParallel extract 0 npm sill doReverseSerial unbuild 0 npm sill doSerial remove 0 npm sill doSerial move 0 npm sill doSerial finalize 0 npm sill doParallel refresh-package-json 0 npm sill doParallel preinstall 0 npm sill doSerial build 0 npm sill doSerial global-link 0 npm sill doParallel update-linked 0 npm sill doSerial install 0 npm sill doSerial postinstall 0 npm verb unlock done using C:\Users\Anne\AppData\Roaming\npm-cache\_locks\staging-75615effd37d994b.lock for G:\Web\程序\3-code\gulp-demo\node_modules\.staging npm timing stage:executeActions Completed in 223ms npm timing stage:rollbackFailedOptional Completed in 0ms npm sill install runPostinstallTopLevelLifecycles npm sill build gulp-demo npm info linkStuff !invalid#1 npm sill linkStuff !invalid#1 has G:\Web\程序\3-code as its parent node_modules npm sill install gulp-demo npm info lifecycle undefined~install: undefined npm sill postinstall gulp-demo npm info lifecycle undefined~postinstall: undefined npm sill prepublish gulp-demo npm info lifecycle undefined~prepublish: undefined npm info lifecycle undefined~prepare: undefined npm timing stage:runTopLevelLifecycles Completed in 407ms npm sill saveTree gulp-demo npm sill install saveToDependencies npm WARN saveError ENOENT: no such file or directory, open 'G:\Web\程序\3-code\gulp-demo\package.json' npm info lifecycle undefined~preshrinkwrap: undefined npm info lifecycle undefined~shrinkwrap: undefined npm notice created a lockfile as package-lock.json. You should commit this file. npm info lifecycle undefined~postshrinkwrap: undefined npm WARN enoent ENOENT: no such file or directory, open 'G:\Web\程序\3-code\gulp-demo\package.json' npm verb enoent This is related to npm not being able to find a file. npm verb enoent npm WARN gulp-demo No description npm WARN gulp-demo No repository field. npm WARN gulp-demo No README data npm WARN gulp-demo No license field. npm sill install printInstalled npm http fetch POST 404 https://registry.npm.taobao.org/-/npm/v1/security/audits/quick 676ms up to date in 0.792s npm verb exit [ 0, true ] npm timing npm Completed in 3577ms npm info ok PS G:\Web\程序\3-code\gulp-demo> npm install npm WARN saveError ENOENT: no such file or directory, open 'G:\Web\程序\3-code\gulp-demo\package.json' npm WARN enoent ENOENT: no such file or directory, open 'G:\Web\程序\3-code\gulp-demo\package.json' npm WARN gulp-demo No description npm WARN gulp-demo No repository field. npm WARN gulp-demo No README data npm WARN gulp-demo No license field. up to date in 0.635s PS G:\Web\程序\3-code\gulp-demo> PS G:\Web\程序\3-code\gulp-demo> npm install nodemon > nodemon@2.0.4 postinstall G:\Web\程序\3-code\gulp-demo\node_modules\nodemon > node bin/postinstall || exit 0 npm WARN saveError ENOENT: no such file or directory, open 'G:\Web\程序\3-code\gulp-demo\package.json' npm WARN enoent ENOENT: no such file or directory, open 'G:\Web\程序\3-code\gulp-demo\package.json' npm WARN gulp-demo No description npm WARN gulp-demo No repository field. npm WARN gulp-demo No README data npm WARN gulp-demo No license field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + nodemon@2.0.4 added 120 packages from 54 contributors in 23.948s 10 packages are looking for funding run `npm fund` for details[参考原帖链接] https://blog.csdn.net/longzhoufeng/article/details/104961342