【问题标题】:Error: "The operation was rejected by your operating system" when trying to create new angular project using windows powershell错误:尝试使用 Windows Powershell 创建新的 Angular 项目时,“操作被您的操作系统拒绝”
【发布时间】:2019-11-11 17:41:43
【问题描述】:

在尝试创建新的 Angular 项目时,我不断收到相同的错误消息。 我尝试使用 Windows Powershell 使用以下命令创建一个新的 Angular 项目:

新的你好世界

-> 你想添加角度路由吗? - 是的

-> 样式表格式? - CSS

我收到以下错误消息。我已经尝试重新安装 angular cli,并且正在使用管理员运行 Powershell。

已安装的版本:

Angular CLI:8.0.6

节点:10.16.0

操作系统:win32 x64

错误信息:

npm WARN tarball data for tslint@~5.15.0 (sha512-6bIEujKR21/3nyeoX2uBnE8s+tMXCQXhqMmaIPJpHmXJoBJPTLcI7/VHRtUwMhnLVdwLqqY3zmd8Dxqa5CVdJA==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for jasmine-spec-reporter@~4.2.1 (sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for acorn@^6.0.5 (sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for @angular/language-service@~8.0.3 (sha512-04XojOo9FJgEQE/rZafnaJQxPEU+//TSzTgpGoIVzCSMx+joCY/ZSSwJZPWxiHlOE57W/zX02ZY+TwcM81oTdw==) seems to be corrupted. Trying one more time.
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\@angular\platform-browser-447d0944\esm2015\animations\src\animation_builder.js'
npm ERR! path C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif',
npm ERR!   parent: 'hello-world' }
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 WARN tar EPERM: operation not permitted, lstat 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\@angular\router-8388bfd5\esm2015\src\directives'
npm WARN tarball tarball data for typescript@3.4.4 (sha512-xt5RsIRCEaf6+j9AyOBgvVuAec0i92rgCaS3S+UVf5Z/vF2Hvtsw08wtUTJqp4djwznoAgjSxeCcU4r+CcDBJA==) seems to be corrupted. Trying one more time.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\konta\AppData\Roaming\npm-cache\_logs\2019-07-01T01_21_13_653Z-debug.log
Package install failed, see above.

【问题讨论】:

    标签: node.js angular powershell


    【解决方案1】:

    我发现了问题:我的防病毒软件在我不知情的情况下以某种方式阻止了文件。一旦我在安装过程中暂停了我的防病毒软件,它就起作用了。

    【讨论】:

    • 这也是我的 MalwareBytes 问题
    • Windows 10 中的出厂配置可能会发生这种情况 - 我遇到了 Windows Defender 的问题 - 另请参阅 Qadir Hussain 的回答。
    • 对我来说也是 MalwareBytes
    【解决方案2】:

    在 windows10 中,我禁用了 windows Defender / windows security ==> 实时保护并再次尝试 npm install 命令,它起作用了

    1。

    2。

    3。

    注意:安装完成后再次开启实时保护。

    【讨论】:

    • 现在的问题是您的 PC 或笔记本电脑没有受到保护... Windows 安全性中有一个选项可以让您排除文件。
    • 作为 Node 的绝对新手,这太可怕了。为什么像nodejs这样成熟的软件需要关闭病毒防护。这在很多层面上都是错误的。
    【解决方案3】:

    重启机器对我有用。

    【讨论】:

      【解决方案4】:

      我尝试使用 以管理员身份运行 打开 CMD,然后运行 ​​npm i,它对我有用

      【讨论】:

        【解决方案5】:

        我只想根据 Qadir Hussain 的回答添加一个小小的回答。

        如果您在 Windows 安全中心中禁用“实时保护”,您的笔记本电脑或 PC 将容易受到任何病毒的攻击,这些病毒在“实时保护”关闭时可能会感染它。如果你只是安装一个 NPM 包,这似乎有点不可能,但有些应用可能有一个隐藏的后台进程等待“实时保护”被禁用,当它被禁用时,它可能会注入病毒。

        话虽如此,还是有办法的。

        1. 首先,通过在“开始”菜单中键入“Windows 安全”并点击“打开”来打开 Windows 安全。

        1. 之后,转到“病毒和威胁防护”。

        1. 接下来,向下滚动,直到在“病毒和威胁防护设置”下找到“管理设置”。

        1. 然后,向下滚动直到看到“排除项”。在“排除项”下有一个链接显示“添加或删除排除项”。

        1. 完成后,点击“添加排除项”按钮。然后点击下拉菜单中的“文件夹”。

        1. 选择出现问题的node_modules 目录。

        2. 最后但同样重要的是,允许管理权限。

        3. 最后,退出 Windows 安全。

        我不建议您排除整个 Projects 文件夹,因为这将禁用对该目录的所有扫描。

        这里的小免责声明,我只是将这个答案作为帮助他人的一种方式,而不会禁用“实时保护”。虽然我不鼓励这样做,但这可能有助于解决一个常见问题。

        祝你有美好的一天。 :)

        【讨论】:

          【解决方案6】:

          对我来说,有几种可能:

          1. 被杀毒软件拦截,导致无法运行。

          2. 被IDE锁定,导致无法操作。

          3. 任务被npm运行锁定,导致无法运行。

          【讨论】:

          • 关闭 Visual Studio 为我修复了它。
          【解决方案7】:

          取消npm start 进程并关闭终端窗口(我使用超级终端)对我有用(使用 Win 10)。

          然后我可以卸载一个 npm 包并安装另一个。

          【讨论】:

          • 我在为我的 React Native 项目安装 npm 包时遇到了麻烦,并且终止了 npm start 进程对我有用。谢谢你!
          【解决方案8】:

          遇到了这个问题,这就是它的解决方法: - 停止执行前端和后端的开发服务器:

          【讨论】:

            【解决方案9】:

            我运行了 Visual Studio 代码。我把它关掉了,砰!为我工作!

            【讨论】:

              【解决方案10】:

              两件事:

              1. 尝试管理员。
              2. 确保其他进程不占用文件夹/文件

              对我来说,这与防病毒无关。 似乎有一个进程占用了这个文件夹。在我的情况下,一个节点进程占用了我的 node_modules 文件夹。 我通过使用process-explorer 找到了它 - 我搜索了路径末尾发现使用此文件夹的节点进程(即使我关闭了它!在 Windows 中很常见),所以我结束了这个进程,然后我没有再收到这个错误了.

              【讨论】:

                【解决方案11】:

                我遇到了同样的问题我做错了我将npm registry 设置为local registry,却不知道我在使用npm config set registry https://registry.npmjs.org/ 重置为全局时遇到了这个问题错误消失了。

                【讨论】:

                  【解决方案12】:

                  对我而言,使用 Windows 10 解决此问题的唯一方法是:排除 node_modules 文件夹,在项目文件夹中以 Admin 模式打开 Visual Studio Code,然后执行以下命令:

                  npm install -g --unsafe-perm
                  

                  【讨论】:

                    【解决方案13】:

                    这发生在我尝试安装新的 npm 依赖项 jest 时:

                    npm i --save-dev jest
                    

                    我只需重新运行命令即可使其正常工作。

                    【讨论】:

                      【解决方案14】:

                      我在 MAC 上遇到了这个问题。我刚刚在命令前添加了“sudo”,它就起作用了。

                      sudo npm install -g parcel-bundler
                      

                      【讨论】:

                        【解决方案15】:

                        上面的方法我都试过了。

                        删除node_modules 并重新安装对我有用。

                        【讨论】:

                          猜你喜欢
                          • 2021-03-10
                          • 2020-08-18
                          • 1970-01-01
                          • 2020-07-04
                          • 2019-12-26
                          • 1970-01-01
                          • 1970-01-01
                          • 2023-02-07
                          • 1970-01-01
                          相关资源
                          最近更新 更多