简体   繁体   English

Npm 错误! 代码 EPERM

[英]Npm ERR! code EPERM

I'm using node v6.11.2, npm v5.3.0 and angular/cli v1.2.7.我正在使用节点 v6.11.2、npm v5.3.0 和 angular/cli v1.2.7。

I'm suddenly receiving the following error message for a majority of my npm installs.对于我的大部分 npm 安装,我突然收到以下错误消息。 Never seen it before...以前从没见过...

mmeppiel@MC-LT-MMEPPIEL MINGW64 ~/Desktop/Angular Solutions/my-app (master)
$ npm install --save bootstrap@4.0.0-alpha.6 font-awesome
npm ERR! path C:\Users\mmeppiel\Desktop\Angular Solutions\my-app\node_modules\fs                            events\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\mmeppiel\Desktop                            \Angular Solutions\my-app\node_modules\fsevents\node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, lstat 'C:\Users\mmeppiel\Desk                            top\Angular Solutions\my-app\node_modules\fsevents\node_modules'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\mme                            ppiel\\Desktop\\Angular Solutions\\my-app\\node_modules\\fsevents\\node_modules\                            '\n    at Error (native)',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path: 'C:\\Users\\mmeppiel\\Desktop\\Angular Solutions\\my-app\\node_                            modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mmeppiel\AppData\Roaming\npm-cache\_logs\2017-08-08T00_56_                            59_442Z-debug.log

Can anyone explain what's going on here?谁能解释这里发生了什么? Things I've tried:我尝试过的事情:

  • Running Git Bash as an administrator以管理员身份运行 Git Bash
  • Turning off my firewall and AntiVirus protections关闭我的防火墙和防病毒保护
  • Running npm cache clean运行 npm 缓存清理
  • Manually deleting the contest of AppData\Roaming\npm-cache手动删除 AppData\Roaming\npm-cache 的比赛
  • Uninstalling node via the Control Panel and reinstalling通过控制面板卸载节点并重新安装
  • Gave Everyone full permissions to C:\Program Files\nodejs授予所有人对 C:\Program Files\nodejs 的完全权限
  • Reinstalled the CLI重新安装了 CLI
  • Restarted my computer (can't hurt?)重新启动我的电脑(不会受伤吗?)
  • Made sure the node_modules folder is not read only确保 node_modules 文件夹不是只读的

Appreciate your time!珍惜你的时间!

I get this error when running Visual Studio Code because the typescript compiler watches files and locks them (see https://github.com/Microsoft/vscode/issues/28593 ).运行 Visual Studio Code 时出现此错误,因为打字稿编译器会监视文件并锁定它们(请参阅https://github.com/Microsoft/vscode/issues/28593 )。 The solution is to temporarily close VS Code when dealing with NPM.解决方法是在处理 NPM 时暂时关闭 VS Code。 Perhaps you have something watching files?也许你有东西看文件?

Are you using any private or company registry.您是否使用任何私人或公司注册表。 check your .npmrc file and make sure its available.检查您的.npmrc文件并确保其可用。

if you are in company environment, make sure proxy is not a problem.如果您在公司环境中,请确保代理没有问题。

check in your folder if any package-lock.json is generated.如果生成了 package-lock.json,请检查您的文件夹。 you can delete that make re install.你可以删除那个重新安装。

I have little doubt but node 6.xx with npm 5.xx might be a problem as node 7.xx is compatible arable with 5.xx And normally node 6.xx is compatible with npm 4.xx我毫不怀疑,但节点 6.xx 与 npm 5.xx 可能是一个问题,因为节点 7.xx 与 5.xx 兼容,通常节点 6.xx 与 npm 4.xx 兼容

I'm having the same problem, even using Node v8.6.0 and npm v5.4.2 .我有同样的问题,即使使用Node v8.6.0npm v5.4.2

Solved with:解决了:

npm cache clean --force

& &

npm install [package] --force

Reference: npm wiki's troubleshooting guide .参考: npm wiki 的故障排除指南

This might help https://alastaircrabtree.com/fixing-intermittant-eperm-operation-not-permitted-on-npm-install/这可能会有所帮助https://alastaircrabtree.com/fixing-intermittant-eperm-operation-not-permitted-on-npm-install/

Also try to play with different node versions the best way of upgrading/switching your node on Windows is to use nvm-windows this way you can have multiple node versions installed on your dev machine you can switch across.也可以尝试用不同的播放node版本升级的最佳途径/切换您的node上的Windows是使用NVM窗口这种方式,您可以安装在您的dev的机器,你可以切换跨多个节点的版本。

UPDATE 0:更新0:

When you dealing with such a problems you have to make sure that nothing is locking our node_modules folder like your Code Editor(eg VS Code, ect) or you might be running npm start in another console window, etc当您处理此类问题时,您必须确保没有任何东西像您的代码编辑器(例如 VS Code 等)那样锁定我们的node_modules文件夹,或者您可能正在另一个控制台窗口中运行npm start

UPDATE 1:更新1:

If you still experiencing the issue try completely to uninstall both node and npm from your system.如果您仍然遇到问题,请尝试从系统中完全卸载 node 和 npm Then restart your machine and install node and npm again.然后重新启动机器并再次安装 node 和 npm。

HOWEVER然而

It is seams like it is common issue by looking in to the npm issues filtering by npm ERR! code EPERM通过查看npm ERR! code EPERM过滤的npm ERR! code EPERM问题,这似乎是一个常见问题npm ERR! code EPERM npm ERR! code EPERM . npm ERR! code EPERM If you browse some of these issues you will see that some people saying that switching the node version is actually help(exactly I was saying at first above) so you need to play with nvm-windows and see what node version is working best for you.如果您浏览其中的一些问题,您会发现有些人说切换节点版本实际上是有帮助的(正是我在上面说的)所以您需要使用nvm-windows并查看哪个节点版本最适合您.

Once you have nvm-windows installed you can do:安装nvm-windows 后,您可以执行以下操作:

  • nvm list - shows all your local node versions you can switch to nvm list - 显示您可以切换到的所有本地节点版本
  • nvm list available - shows all actual node versions that you can install locally nvm list available - 显示您可以在本地安装的所有实际节点版本
  • nvm install <version number> - install(download+install) a particular node version nvm install <version number> - 安装(下载+安装)一个特定的节点版本
  • nvm use <version number> switch to particular node version nvm use <version number>切换到特定节点版本
  • nvm help - will give you help nvm help - 会给你帮助

If you jump from major version of npm some of your packages that you installed with a previous node version might no longer work so you have to be reinstall them如果您从 npm 的主要版本跳转,您使用先前节点版本安装的某些软件包可能不再有效,因此您必须重新安装它们

Run windows command prompt as administrator.以管理员身份运行 Windows 命令提示符。 Then navigate ("cd directoryName")to your project folder do "npm install".然后导航(“cd directoryName”)到您的项目文件夹执行“npm install”。

Resolved this by installing typescript globally.通过全局安装打字稿解决了这个问题。 The Angular Compiler requires TypeScript >=3.1.1 and <3.3.0 Changed the version in the package.json to the installed version. Angular Compiler 需要 TypeScript >=3.1.1 和 <3.3.0 将 package.json 中的版本更改为已安装的版本。 Then did an npm install然后做了一个 npm 安装

    npm install -g typescript
    npm info typescript version
    npm install

Very similar problem, only the specific complaint was that scandir was failing on a certain subfolder (fsevents) in the new app's target directory.非常相似的问题,只有特定的抱怨是新应用程序目标目录中的某个子文件夹 (fsevents) 上的 scandir 失败。 I checked and found that the folder in question did not even exist because it was the product of an optional dependency which was skipped on npm install because I was on Windows and not Linux.我检查并发现有问题的文件夹甚至不存在,因为它是可选依赖项的产物,在 npm install 上跳过,因为我使用的是 Windows 而不是 Linux。

The script running the app build command runs in such a way to compensate for this when "ng new " is run under Windows PowerShell.当在 Windows PowerShell 下运行“ng new”时,运行 app build 命令的脚本会以这种方式运行以补偿这种情况。 It does not work when run in an ordinary cmd window.在普通 cmd 窗口中运行时不起作用。 So in my case the fix was simply to run "ng new under Windows PowerShell instead of in a cmd window and the install completed successfully -- finally, after having tried several other things.所以在我的情况下,修复只是在 Windows PowerShell 下而不是在 cmd 窗口中运行“ng new”并且安装成功完成——最后,在尝试了其他几件事之后。

Normally we assume that "tns run android" command will also setup the android plateform, which failed for me two times and then I resolved it by running the following two commands in the given order:通常我们假设“tns run android”命令也会设置android平台,这对我来说失败了两次,然后我通过按给定顺序运行以下两个命令来解决它:

   tns platform add android
   tns run android

Try running command prompt as administrator.尝试以管理员身份运行命令提示符。 Worked for me.为我工作。

Usually its because of no permission to access the folders inside C:/Users/... If you have created your project in the C:/Users/.. folder, you need to get administrative permission to make changes to that folder.通常是因为没有权限访问 C:/Users/... 中的文件夹。如果您在 C:/Users/.. 文件夹中创建了项目,则需要获得管理权限才能对该文件夹进行更改。 Run your Code Editor As Administrator.以管理员身份运行代码编辑器。 This will allow the program to make changes to that folder.这将允许程序对该文件夹进行更改。

我在使用 VS CODE 终端时遇到了同样的问题,您可以以管理员或 root 身份打开 cmd 或 bash,然后只需npm install (your package)

SOLUTION SPECIFIC FOR ANGULAR APPLICATION角度应用的特定解决方案

Turn off your angular compiler (ie. ng serve) & again try to install the package

Works for me every time.每次都对我有用。

I faced this problem when I went to install the react-rating package.我在安装 react-rating 包时遇到了这个问题。 I just switched from npm to yarn and it was solved.我刚刚从 npm 切换到 yarn 并解决了。

That means instead of npm install --save react-rating I used yarn add react-rating这意味着我使用了 yarn add react-rating 而不是 npm install --save react-rating

If you have it in gatsby.js.如果你在 gatsby.js 中有它。 I had problem with timeouts.我有超时问题。 This fixed it, you should add it to envs:这修复了它,您应该将其添加到 envs:

CONNECTION_TIMEOUT=600000
STALL_RETRY_LIMIT=10
STALL_TIMEOUT=60000
GATSBY_CONCURRENT_DOWNLOAD=1

The problem is you're on the incorrect version of node for your operating system.问题是您的操作系统使用的节点版本不正确。 It's trying to fetch lstat (a POSIX syscall) which doesn't exist on Windows.它试图获取 Windows 上不存在的 lstat(一个 POSIX 系统调用)。

Currently I do not have a solution other than install the correct npm目前,除了install the correct npm之外,我没有其他解决方案

Hopefully this helped you !希望这对你有帮助!

https://linux.die.net/man/2/lstat https://linux.die.net/man/2/lstat

EDIT If you can't find a fix i'd suggest for you to go to the Github Issue page.编辑如果您找不到修复程序,我建议您转到 Github 问题页面。

It might be the most basic solution, but an EPERM error can be resolved only by giving permission.这可能是最基本的解决方案,但 EPERM 错误只能通过授予权限来解决。

  1. Deactivate any anti-virus software (until complete install) that there are on your PC.停用您 PC 上的所有防病毒软件(直到完成安装)。

  2. Make sure that the adb.exe file (if there is) is not running on the background.确保adb.exe文件(如果有)没有在后台运行。

    To do this, open the task manager, go to the 'Processes' tab and end the adb.exe process.为此,请打开任务管理器,转到“进程”选项卡并结束 adb.exe 进程。

  3. Uninstall incomplete previous installs of expo-cli by running the command通过运行命令卸载以前安装的 expo-cli

    npm uninstall -g expo-cli --save npm uninstall -g expo-cli --save

  4. Now, install the expo-cli app现在,安装expo-cli 应用程序

    npm install -g expo-cli npm install -g expo-cli

This has done the trick in my case.在我的情况下,这已经成功了。 Might do for somebody else as well.也可以为别人做。

Cheers!干杯!

Delete node modules and run npm cache clean --force删除节点模块并运行npm cache clean --force

Then run,然后跑,

npm install --save

Worked for me为我工作

I had the same problem.我有同样的问题。 I delete the package-lock.json and rerun npm install again.我删除了 package-lock.json 并重新运行 npm 安装。 Problem solved.问题解决了。

I tried every method listed here, but nothing seemed to work.我尝试了此处列出的所有方法,但似乎没有任何效果。 So I uninstalled that was installed from the Windows Control Panel's Add/Remove Programs list then installed with the new version of node所以我卸载了从 Windows 控制面板的添加/删除程序列表中安装的,然后安装了新版本的节点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM