node.js 错误!代码 EPERM

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45557788/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:24:44  来源:igfitidea点击:

Npm ERR! code EPERM

node.jsangularnpmangular-clinpm-install

提问by Matthew Meppiel

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. Never seen it before...

对于我的大多数 npm 安装,我突然收到以下错误消息。以前没见过...

mmeppiel@MC-LT-MMEPPIEL MINGW64 ~/Desktop/Angular Solutions/my-app (master)
$ npm install --save [email protected] 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\_logs17-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
  • Turning off my firewall and AntiVirus protections
  • Running npm cache clean
  • Manually deleting the contest of AppData\Roaming\npm-cache
  • Uninstalling node via the Control Panel and reinstalling
  • Gave Everyone full permissions to C:\Program Files\nodejs
  • Reinstalled the CLI
  • Restarted my computer (can't hurt?)
  • Made sure the node_modules folder is not read only
  • 以管理员身份运行 Git Bash
  • 关闭我的防火墙和防病毒保护
  • 运行 npm cache clean
  • 手动删除 AppData\Roaming\npm-cache 的竞赛
  • 通过控制面板卸载节点并重新安装
  • 授予每个人对 C:\Program Files\nodejs 的完全权限
  • 重新安装了 CLI
  • 重新启动我的电脑(不会受伤吗?)
  • 确保 node_modules 文件夹不是只读的

Appreciate your time!

珍惜你的时间!

采纳答案by Aniruddha Das

Are you using any private or company registry. check your .npmrcfile 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. you can delete that make re install.

如果生成了 package-lock.json,请检查您的文件夹。你可以删除那个重新安装。

I have little doubt but node 6.x.x with npm 5.x.x might be a problem as node 7.x.x is compatible arable with 5.x.x. And normally node 6.x.x is compatible with npm 4.x.x

我毫不怀疑,但节点 6.xx 与 npm 5.xx 可能是一个问题,因为节点 7.xx 与 5.xx 兼容,通常节点 6.xx 与 npm 4.xx 兼容

回答by James Ehly

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). The solution is to temporarily close VS Code when dealing with NPM. Perhaps you have something watching files?

运行 Visual Studio Code 时出现此错误,因为打字稿编译器会监视文件并锁定它们(请参阅https://github.com/Microsoft/vscode/issues/28593)。解决方法是在处理 NPM 时暂时关闭 VS Code。也许你有东西看文件?

回答by ranieribt

I'm having the same problem, even using Node v8.6.0and npm v5.4.2.

我有同样的问题,即使使用Node v8.6.0npm v5.4.2

Solved with:

解决了:

npm cache clean --force

npm cache clean --force

&

&

npm install [package] --force

npm install [package] --force

Reference: npm wiki's troubleshooting guide.

参考:npm wiki 的故障排除指南

回答by kuncevic.dev

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 nodeversions the best way of upgrading/switching your nodeon Windows is to use nvm-windowsthis way you can have multiple node versions installed on your dev machine you can switch across.

还尝试使用不同的node版本,node在 Windows上升级/切换的最佳方法是使用nvm-windows,这样您就可以在开发机器上安装多个节点版本,您可以切换。

UPDATE 0:

更新0:

When you dealing with such a problems you have to make sure that nothing is locking our node_modulesfolder like your Code Editor(e.g VS Code, ect) or you might be running npm startin another console window, etc

当您处理此类问题时,您必须确保没有任何东西node_modules像您的代码编辑器(例如 VS Code 等)那样锁定我们的文件夹,或者您可能正在npm start另一个控制台窗口中运行等

UPDATE 1:

更新1:

If you still experiencing the issue try completely to uninstall both node and npmfrom your system. Then restart your machine and install node and npm again.

如果您仍然遇到问题,请尝试从系统中完全卸载 node 和 npm。然后重新启动机器并再次安装 node 和 npm。

HOWEVER

然而

It is seams like it is common issue by looking in to the npm issues filtering by 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-windowsand see what node version is working best for you.

通过查看npm ERR! code EPERM. 如果您浏览其中一些问题,您会发现有些人说切换节点版本实际上是有帮助的(正是我在上面说的)所以您需要使用nvm-windows并查看哪个节点版本最适合您.

Once you have nvm-windowsinstalled you can do:

一旦你有NVM-windows的安装可以这样做:

  • nvm list- shows all your local node versions you can switch to
  • nvm list available- shows all actual node versionsthat you can install locally
  • nvm install <version number>- install(download+install) a particular node version
  • nvm use <version number>switch to particular node version
  • nvm help- will give you help
  • nvm list- 显示您可以切换到的所有本地节点版本
  • nvm list available- 显示您可以在本地安装的所有实际节点版本
  • nvm install <version number>- 安装(下载+安装)一个特定的节点版本
  • nvm use <version number>切换到特定节点版本
  • 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 的主要版本跳转,则您使用先前节点版本安装的某些软件包可能不再有效,因此您必须重新安装它们

回答by Matt Campbell

Very similar problem, only the specific complaint was that scandir was failing on a certain subfolder (fsevents) in the new app's target directory. 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.

非常相似的问题,只有特定的抱怨是新应用程序目标目录中的某个子文件夹 (fsevents) 上的 scandir 失败。我检查并发现有问题的文件夹甚至不存在,因为它是可选依赖项的产物,在 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. It does not work when run in an ordinary cmd window. 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 下运行“ng new”时,运行 app build 命令的脚本会以这种方式运行以补偿这种情况。在普通 cmd 窗口中运行时不起作用。因此,在我的情况下,修复只是在 Windows PowerShell 下而不是在 cmd 窗口中运行“ng new”并且安装成功完成 - 最后,在尝试了其他几件事之后。

回答by JUSTIN JOSEPH

Run windows command prompt as administrator. Then navigate ("cd directoryName")to your project folder do "npm install".

以管理员身份运行 Windows 命令提示符。然后导航(“cd directoryName”)到您的项目文件夹执行“npm install”。

回答by Mukhtiar Zamin

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

回答by Glitch

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. Then did an npm install

通过全局安装打字稿解决了这个问题。Angular Compiler 需要 TypeScript >=3.1.1 和 <3.3.0 将 package.json 中的版本更改为已安装的版本。然后做了一个 npm 安装

    npm install -g typescript
    npm info typescript version
    npm install

回答by Rithika Akula

It might be the most basic solution, but an EPERM error can be resolved only by giving permission.

这可能是最基本的解决方案,但 EPERM 错误只能通过授予权限来解决。

  1. Deactivateany anti-virus software (until complete install) that there are on your PC.

  2. Make sure that the adb.exefile (if there is) is not running on the background.

    To do this, open the task manager, go to the 'Processes' tab and end the adb.exe process.

  3. Uninstallincomplete previous installs of expo-cli by running the command

    npm uninstall -g expo-cli --save

  4. Now, installthe expo-cli app

    npm install -g expo-cli

  1. 停用您 PC 上的所有防病毒软件(直到完成安装)。

  2. 确保adb.exe文件(如果有)没有在后台运行。

    为此,请打开任务管理器,转到“进程”选项卡并结束 adb.exe 进程。

  3. 通过运行命令卸载以前安装的 expo-cli

    npm uninstall -g expo-cli --save

  4. 现在,安装expo-cli 应用程序

    npm install -g expo-cli

This has done the trick in my case. Might do for somebody else as well.

在我的情况下,这已经成功了。也可以为别人做。

Cheers!

干杯!

回答by Adnan Temur

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. Run your Code Editor As Administrator.This will allow the program to make changes to that folder.

通常是因为没有权限访问 C:/Users/... 中的文件夹。如果您在 C:/Users/.. 文件夹中创建了项目,则需要获得管理权限才能对该文件夹进行更改。 以管理员身份运行代码编辑器。这将允许程序对该文件夹进行更改。