简体   繁体   English

npm 安装失败,错误:EPERM:不允许操作,取消链接 '\\node_modules'

[英]npm install failed with Error: EPERM: operation not permitted, unlink '\node_modules'

I try to run "npm install" command in CMD ["node_modules" is inside C drive] but installation failing with below error.我尝试在 CMD 中运行“npm install”命令[“node_modules”在 C 驱动器内],但安装失败并出现以下错误。

OS :Windows 10.

Node JS version: 6.9.0.

Error: EPERM: operation not permitted, unlink.错误:EPERM:不允许操作,取消链接。

Goal: To run AngularJs project.目标:运行 AngularJs 项目。

CMD command CMD 命令

npm install -- no optional;

PS C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular> npm install --no-optional PS C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular> npm install --no-optional

 npm ERR! path C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall unlink npm ERR! Error: EPERM: operation not permitted, unlink 'C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js' npm ERR! [Error: EPERM: operation not permitted, unlink 'C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js'] { npm ERR! stack: 'Error: EPERM: operation not permitted, unlink ' + npm ERR! "'C:\\\\Users\\\\arunk\\\\Work\\\\Workspaces\\\\workspace-2\\\\brainbox-frontend-angular\\\\node_modules\\\\.staging\\\\typescript-5afdc8eb\\\\lib\\\\tsc.js'", npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'unlink', npm ERR! path: 'C:\\\\Users\\\\arunk\\\\Work\\\\Workspaces\\\\workspace-2\\\\brainbox-frontend-angular\\\\node_modules\\\\.staging\\\\typescript-5afdc8eb\\\\lib\\\\tsc.js' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator (though this is not recommended). npm ERR! A complete log of this run can be found in: npm ERR! C:\\Users\\arunk\\AppData\\Roaming\\npm-cache\\_logs\\2019-05-22T19_01_22_659Z-debug.log

I had the same problem and tried a lot of different things.我遇到了同样的问题并尝试了很多不同的事情。 This solved my problem:这解决了我的问题:

1 - Uninstall NodeJs
2 - Delete folders 'npm' and 'npm-cache' from AppData/Roaming
3 - Deactivate firewall and all antivirus (including Windows Defender)
4 - Reboot the system
5 - Open command prompt as administrator and execute 'npm install'

Like you I have wasted much time trying to get 'npm install' to install Angular projects from its 'project.json' file and received similar error messages that are unhelpful;像你一样,我浪费了很多时间试图让 'npm install' 从它的 'project.json' 文件安装 Angular 项目,并收到了类似的无用的错误消息; Recently I installed 'yarn' and this does a much better job of populating the 'node_modules' folder and it also generates more useful error and warning messages in the process.最近我安装了“yarn”,这在填充“node_modules”文件夹方面做得更好,并且在此过程中还会生成更多有用的错误和警告消息。

Try the following steps:尝试以下步骤:

  1. Install 'Yarn' - go to it's website and download the installer for your operating system.安装“Yarn” - 访问其网站并下载适用于您的操作系统的安装程序。

  2. Got to your project directory (the one containing 'project.json')到您的项目目录(包含“project.json”的目录)

  3. enter the command 'yarn' and wait.输入命令“纱线”并等待。 This will perform the same function as 'npm install', however it will generate fewer messages but the ones it does will be more pertinent.这将执行与“npm install”相同的功能,但是它会生成更少的消息,但它所做的将更相关。

I hope this helps.我希望这有帮助。

I was using yarn to install axios and got the same error, but I figured out that this error is not peculiar to axios since the same thing happens with all other packages.我正在使用 yarn 安装 axios 并遇到相同的错误,但我发现这个错误并不是 axios 特有的,因为所有其他包都会发生同样的事情。

Killing all running node process worked for me.杀死所有正在运行的节点进程对我有用。

Perhaps a problem with the file system.可能是文件系统的问题。

Check your C drive with the windows verification tool (right click on the C: -> Properties -> Tools -> Check).使用 Windows 验证工具检查您的 C 驱动器(右键单击 C: -> 属性 -> 工具 -> 检查)。 Repair the errors if it's needed.如果需要,请修复错误。

It worked for me.它对我有用。 I write here this solution for people (like me) with similar issue.我在这里为有类似问题的人(像我一样)写了这个解决方案。

Similar problem can also happen if you try to uninstall a dependency while in another terminal window you're using如果您在正在使用的另一个终端窗口中尝试卸载依赖项,也会发生类似的问题

ng serve

Simply stop that operation and only then you can uninstall it.只需停止该操作,然后您就可以卸载它。

Please try following steps:请尝试以下步骤:

  1. check your antivirus status is enable or disable检查您的防病毒状态是启用还是禁用

  2. disable your antivirus during the installation.在安装过程中禁用防病毒软件。

I hope this helps.我希望这有帮助。 It worked for me.它对我有用。

尝试清除缓存

npm cache clean --force

暂无
暂无

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

相关问题 错误:EPERM:不允许进行操作,请取消链接“ C:\\ wamp64 \\ www \\ dev \\ node_modules \\ .staging” - Error: EPERM: operation not permitted, unlink 'C:\wamp64\www\dev\node_modules\.staging' 删除node_modules,获取错误的EPERM操作不允许 - deleting node_modules, get error EPERM operation not permitted Npm 安装错误 EPERM 不允许操作 - Npm install error EPERM Operation not permitted 错误:EPERM:不允许操作,运行npm publish时取消链接 - Error: EPERM: operation not permitted, unlink when running npm publish npm 发布导致“错误:EPERM:不允许操作,取消链接...”,错误号 -4048 - npm publish causes 'Error: EPERM: operation not permitted, unlink ...', errno -4048 ../node_modules/axios/lib/helpers/cookies.js [1] 错误:EPERM:不允许操作,读取 - ../node_modules/axios/lib/helpers/cookies.js [1] Error: EPERM: operation not permitted, read &quot;EPERM: 不允许操作,取消链接 &#39;C:\\Users\\<user> \\node_modules\\bufferutil\\prebuilds\\win32-ia32\\node.napi.node&#39;&quot; - "EPERM: operation not permitted, unlink 'C:\\Users\\<user>\\node_modules\\bufferutil\\prebuilds\\win32-ia32\\node.napi.node'" EPERM:不允许操作,取消链接 'C:\Users\**\node_modules\.node-sass.DELETE\vendor\win32-x64-57\binding.node' - EPERM: operation not permitted, unlink 'C:\Users\**\node_modules\.node-sass.DELETE\vendor\win32-x64-57\binding.node' npm install -g expo-cli 失败并显示“EPERM:不允许操作,取消链接&#39;...\\adb.exe&#39; - npm install -g expo-cli fails with "EPERM: operation not permitted, unlink '...\adb.exe' Npm install angular/cli 错误 EPERM 不允许操作 - Npm install angular/cli error EPERM Operation not permitted
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM