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

查看:53
本文介绍了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 registry 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:SergiuKnockout Test
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path D:SergiuKnockout Test
ode_modulesgenerator-knockout
ode_modulesyeoman-generator
ode_modules	ar
ode_moduleslock-streamlock-stream.js
npm ERR! fstream_path D:SergiuKnockout Test
ode_modulesgenerator-knockout
ode_modulesyeoman-generator
ode_modules	ar
ode_moduleslock-streamlock-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:SergiuKnockout Test
ode_modulesgenerator-knockout
ode_modulesyeoman-generator
ode_modules	ar
ode_moduleslock-streamlock-stream.js'
npm ERR! fstream_stack C:Program Files
odejs
ode_modules
pm
ode_modulesfstreamlibwriter.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EPERM, lstat 'D:SergiuKnockout Test
ode_modulesgenerator-knockout
ode_modulesyeoman-generator
ode_modules	ar
ode_modulesfstreamLICENSE'
npm ERR!  { [Error: EPERM, lstat 'D:SergiuKnockout Test
ode_modulesgenerator-knockout
ode_modulesyeoman-generator
ode_modules	ar
ode_modulesfstreamLICENSE']
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% pm-cache,或者如果您使用的是 PowerShell,$env:APPDATA pm-缓存.

If that doesn’t fix things, take a look in %APPDATA% pm-cache, or if you’re using PowerShell, $env:APPDATA pm-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 错误!从 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.

(来源:MSDN 博客文章)

这篇关于Npm 请以 root/管理员身份再次尝试使用此命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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