【问题标题】:npm install failed with Error: EPERM: operation not permitted, unlink '\node_modules'npm 安装失败并出现错误:EPERM:不允许操作,取消链接“\node_modules”
【发布时间】:2019-05-22 19:23:44
【问题描述】:

我尝试在 CMD 中运行“npm install”命令 [“node_modules”在 C 盘内],但安装失败并出现以下错误。

OS :Windows 10.

Node JS version: 6.9.0.

错误:EPERM:不允许操作,取消链接。

目标:运行 AngularJs 项目。

CMD 命令

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

【问题讨论】:

    标签: node.js angularjs windows-10 npm-install


    【解决方案1】:

    我遇到了同样的问题并尝试了很多不同的方法。这解决了我的问题:

    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'
    

    【讨论】:

      【解决方案2】:

      和你一样,我浪费了很多时间试图让 'npm install' 从它的 'project.json' 文件中安装 Angular 项目,并且收到了类似的无用的错误消息;最近我安装了“yarn”,它在填充“node_modules”文件夹方面做得更好,并且在此过程中还会生成更多有用的错误和警告消息。

      尝试以下步骤:

      1. 安装“Yarn” - 访问它的网站并为您的操作系统下载安装程序。

      2. 进入您的项目目录(包含“project.json”的目录)

      3. 输入命令“yarn”并等待。这将执行相同的功能 作为'npm install',但是它会生成更少的消息,但那些 它确实会更有针对性。

      我希望这会有所帮助。

      【讨论】:

        【解决方案3】:

        我在使用 yarn 安装 axios 时遇到了同样的错误,但我发现这个错误并不是 axios 特有的,因为所有其他包都会发生同样的情况。

        杀死所有正在运行的节点进程对我有用。

        【讨论】:

          【解决方案4】:

          可能是文件系统有问题。

          用windows验证工具检查你的C盘(右击C:->属性->工具->检查)。如果需要,请修复错误。

          它对我有用。我在这里为有类似问题的人(比如我)写了这个解决方案。

          【讨论】:

            【解决方案5】:

            如果您在正在使用的另一个终端窗口中尝试卸载依赖项,也会发生类似的问题

            ng serve
            

            只需停止该操作,然后您就可以卸载它。

            【讨论】:

              【解决方案6】:

              请尝试以下步骤:

              1. 检查您的防病毒状态是启用还是禁用

              2. 在安装过程中禁用您的防病毒软件。

              我希望这会有所帮助。它对我有用。

              【讨论】:

                猜你喜欢
                • 2019-11-04
                • 2023-03-07
                • 2018-05-26
                • 2018-02-11
                • 1970-01-01
                • 2020-03-05
                • 2018-05-24
                • 2019-10-05
                • 1970-01-01
                相关资源
                最近更新 更多