Npm请以root/管理员身份再次尝试使用此命令 [英] Npm Please try using this command again as root/administrator

查看:707
本文介绍了Npm请以root/管理员身份再次尝试使用此命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在拼命尝试使用node.js安装模块,但始终无法通过npm获取软件包.

I've been desperately trying to install modules using node.js but it always fails getting packages with npm.

我以管理员身份登录,并使用powershell/cmd和以管理员身份运行".我的注册表也有问题,因此我使用了npm set注册表 http://registry.npmjs.org/

I logged in as Administrator and used powershell/cmd with "run as administrator". I also had problems with the registry so I used npm set registry http://registry.npmjs.org/

我尝试了一切...它简直让我发疯.

I tried everything... it just drives me nuts.

以下是错误:

npm错误!请尝试以root/管理员身份再次运行此命令.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "generator-knockout"
npm ERR! cwd D:\Sergiu\Knockout Test
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\block-stream\block-stream.js
npm ERR! fstream_path D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\block-stream\block-stream.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, lstat 'D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\block-stream\block-stream.js'
npm ERR! fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EPERM, lstat 'D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\fstream\LICENSE'
npm ERR!  { [Error: EPERM, lstat 'D:\Sergiu\Knockout Test\node_modules\generator-knockout\node_modules\yeoman-generator\node_modules\tar\node_modules\fstream\LICENSE']
npm ERR!   errno: 50,
npm ERR!   code: 'EPERM',
npm ERR!   path: 'D:\\Sergiu\\Knockout Test\\node_modules\\generator-knockout\\node_modules\\yeoman-generator\\node_modules\\tar\\node_modules\\fstream\\LICENSE',
npm ERR!   fstream_type: 'File',
npm ERR!   fstream_path: 'D:\\Sergiu\\Knockout Test\\node_modules\\generator-knockout\\node_modules\\yeoman-generator\\node_modules\\tar\\node_modules\\fstream\\LICENSE',
npm ERR!   fstream_class: 'FileWriter',
npm ERR!   fstream_stack:
npm ERR!    [ 'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\fstream\\lib\\writer.js:284:26',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

推荐答案

事实证明,您不必以管理员身份再次运行命令,这样做不会解决问题.

It turns out that you don’t have to run the command again as Administrator, and doing so won’t fix the problem.

尝试:

  1. npm cache clean首先.

如果这不能解决问题,请查看%APPDATA%\npm-cache,或者如果使用的是PowerShell,请访问$env:APPDATA\npm-cache.

If that doesn’t fix things, take a look in %APPDATA%\npm-cache, or if you’re using PowerShell, $env:APPDATA\npm-cache.

在清理缓存后,您可能仍然会留下残留物.手动删除该目录中的所有内容,然后重试.这始终为我解决了问题.

After cleaning the cache, you may still be left with remnants. Manually remove everything in that directory, and try again. This has always fixed things for me.

正如@Crazzymatt所提到的那样,从npm @ 5版本开始,我们需要使用npm cache verify而不是npm cache clean.否则,您将收到如前所述的错误.

As @Crazzymatt was mentioning, as of the npm@5 version and up, we need to use npm cache verify instead of npm cache clean. Or else you will get an error as preceding.

npm ERR!从npm @ 5开始,npm缓存会因损坏问题而自我修复,并且保证从缓存中提取的数据是有效的.如果要确保所有内容都一致,请改用"npm缓存验证".

npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.

(来源: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆