使用NodeJS创建角度项目时出现问题

时间:2019-12-26 11:14:16

标签: node.js angular npm

在系统中安装angular-cli后,我试图创建一个项目。当我发出ng new project-name命令时,出现如下错误。

错误:

  
21328 verbose stack Error: EPERM: operation not permitted, unlink 'C:\Windows\System32\sampleproject\node_modules\.staging\typescript-d81c34c0\lib\typescript.js'
21329 verbose cwd C:\Windows\System32\sampleproject
21330 verbose Windows_NT 10.0.17134
21331 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"
21332 verbose node v12.6.0
21333 verbose npm  v6.9.0
21334 error path C:\Windows\System32\sampleproject\node_modules\.staging\typescript-d81c34c0\lib\typescript.js
21335 error code EPERM
21336 error errno -4048
21337 error syscall unlink
21338 error Error: EPERM: operation not permitted, unlink 'C:\Windows\System32\sampleproject\node_modules\.staging\typescript-d81c34c0\lib\typescript.js'
21338 error  [OperationalError: EPERM: operation not permitted, unlink 'C:\Windows\System32\sampleproject\node_modules\.staging\typescript-d81c34c0\lib\typescript.js'] {
21338 error   cause: [Error: EPERM: operation not permitted, unlink 'C:\Windows\System32\sampleproject\node_modules\.staging\typescript-d81c34c0\lib\typescript.js'] {
21338 error     errno: -4048,
21338 error     code: 'EPERM',
21338 error     syscall: 'unlink',
21338 error     path: 'C:\\Windows\\System32\\sampleproject\\node_modules\\.staging\\typescript-d81c34c0\\lib\\typescript.js'
21338 error   },
21338 error   stack: "Error: EPERM: operation not permitted, unlink 'C:\\Windows\\System32\\sampleproject\\node_modules\\.staging\\typescript-d81c34c0\\lib\\typescript.js'",
21338 error   errno: -4048,
21338 error   code: 'EPERM',
21338 error   syscall: 'unlink',
21338 error   path: 'C:\\Windows\\System32\\sampleproject\\node_modules\\.staging\\typescript-d81c34c0\\lib\\typescript.js',
21338 error   parent: 'sampleproject'
21338 error }
21339 error The operation was rejected by your operating system.
21339 error It's possible that the file was already in use (by a text editor or antivirus),
21339 error or that you lack permissions to access it.
21339 error
21339 error If you believe this might be a permissions issue, please double-check the
21339 error permissions of the file and its containing directories, or try running
21339 error the command again as root/Administrator (though this is not recommended).
21340 verbose exit [ -4048, true ]

这是什么问题,以及如何解决?

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

似乎是Windows权限问题,请首先尝试执行以下操作:

npm cache clean

如果这不能解决问题,请查看%APPDATA%\npm-cache清理此目录,或者在PowerShell中运行$env:APPDATA\npm-cache

在清理缓存后,您可能仍然会留下残留物。手动删除该目录中的所有内容,然后重试。