错误:尝试使用 windows powershell 创建新的 angular 项目时,“操作被您的操作系统拒绝”

nic*_*as_ 16 powershell node.js angular

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

ng 新的你好世界

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

-> 样式表格式?- CSS

我得到了下面的错误信息。我已经尝试重新安装 angular cli,并且正在使用管理员运行 Powershell。

已安装版本:

角 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.
Run Code Online (Sandbox Code Playgroud)

nic*_*as_ 13

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


小智 13

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

sudo npm install -g parcel-bundler
Run Code Online (Sandbox Code Playgroud)


Dul*_*oon 12

重新启动机器对我有用。


Qad*_*ain 11

在 windows10 中,我禁用了 windows 防御者/windows 安全 ==> 实时保护,然后再试一次 npm install 命令,它起作用了

1. 在此处输入图片说明

2. 在此处输入图片说明

3. 在此处输入图片说明

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

  • 现在的问题是您的 PC 或笔记本电脑不受保护...Windows 安全中有一个选项允许您排除文件。 (2认同)

小智 6

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


Edw*_*att 5

我只想根据卡迪尔·侯赛因的答案添加一个小答案。

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

话虽如此,仍然有一个选择。

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

在“开始”菜单中键入“Windows 安全”,然后点击“打开”。

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

转到“病毒和威胁防护”。

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

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

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

向下滚动,直到看到“添加或删除排除项”链接。

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

点击“添加排除项”按钮。 然后点击下拉菜单上的“文件夹”。

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

  2. 最后但并非最不重要的一点是,允许管理权限。

  3. 最后,退出Windows安全。

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

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

祝你有美好的一天。:)