简体   繁体   English

Angular ng 新返回包安装失败错误 - compiler.umd.js 丢失

[英]Angular ng new returns package install failed error - compiler.umd.js missing

I am trying to learn Angular and am following an online tutorial.我正在尝试学习 Angular,并且正在学习在线教程。 However, I can't seem to get past creating a new project with ng new.但是,我似乎无法使用 ng new 创建一个新项目。 I am running node v10.16.0 and npm 6.9.0 on Windows 7. I get the following error in the log:我在 Windows 7 上运行 node v10.16.0 和 npm 6.9.0。我在日志中收到以下错误:

15177 verbose cwd C:\Personal documents\Angular\myProject
15178 verbose Windows_NT 6.1.7601
15179 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"
15180 verbose node v10.16.0
15181 verbose npm  v6.9.0
15182 error path C:\Personal documents\Angular\myProject\node_modules\.staging\typescript-f4316380\lib\lib.dom.d.ts
15183 error code EPERM
15184 error errno -4048
15185 error syscall unlink
15186 error Error: EPERM: operation not permitted, unlink 'C:\Personal documents\Angular\myProject\node_modules\.staging\typescript-f4316380\lib\lib.dom.d.ts'
15186 error  { [Error: EPERM: operation not permitted, unlink 'C:\Personal documents\Angular\myProject\node_modules\.staging\typescript-f4316380\lib\lib.dom.d.ts']
15186 error   cause:
15186 error    { Error: EPERM: operation not permitted, unlink 'C:\Personal documents\Angular\myProject\node_modules\.staging\typescript-f4316380\lib\lib.dom.d.ts'
15186 error      errno: -4048,
15186 error      code: 'EPERM',
15186 error      syscall: 'unlink',
15186 error      path:
15186 error       'C:\\Personal documents\\Angular\\myProject\\node_modules\\.staging\\typescript-f4316380\\lib\\lib.dom.d.ts' },
15186 error   stack:
15186 error    'Error: EPERM: operation not permitted, unlink \'C:\\Personal documents\\Angular\\myProject\\node_modules\\.staging\\typescript-f4316380\\lib\\lib.dom.d.ts\'',
15186 error   errno: -4048,
15186 error   code: 'EPERM',
15186 error   syscall: 'unlink',
15186 error   path:
15186 error    'C:\\Personal documents\\Angular\\myProject\\node_modules\\.staging\\typescript-f4316380\\lib\\lib.dom.d.ts',
15186 error   parent: '@angular-devkit/build-optimizer' }
15187 error The operation was rejected by your operating system.
15187 error It's possible that the file was already in use (by a text editor or antivirus),
15187 error or that you lack permissions to access it.
15187 error
15187 error If you believe this might be a permissions issue, please double-check the
15187 error permissions of the file and its containing directories, or try running
15187 error the command again as root/Administrator (though this is not recommended).
15188 verbose exit [ -4048, true ]

I followed the path specified above and the lib folders are empty.我遵循上面指定的路径,lib 文件夹是空的。 I tried reinstalling node, reinstalling angular, clearing the cache with --force, running as administrator, restarting.我尝试重新安装节点,重新安装 angular,使用 --force 清除缓存,以管理员身份运行,重新启动。 Nothing is helping.没有任何帮助。

Please note that I am a complete noob at this and am just trying to learn the framework, which right now seems impossible to work with.请注意,我在这方面完全是个菜鸟,我只是想学习这个框架,现在似乎无法使用它。

I expect the packages to install and the project to be created without issues.我希望安装软件包和创建项目没有问题。

For some reasons when angular/cli (ng) run npm install by itself, it have problem with packages writing, so you can run由于某些原因,angular/cli (ng) 自己运行 npm install 时,写包有问题,所以你可以运行

ng new yourProject --skipInstall=true

so angular/cli will not install any node packages and then run所以 angular/cli 不会安装任何节点包然后运行

npm install --force

to install it by yourself自己安装

I've faced like this issue and the solution was:我遇到过这样的问题,解决方案是:

  1. Go to Edit the system environment variables .转到编辑系统环境变量
  2. Under User variables for User ==> Path , Make sure C:\\Users\\user\\AppData\\Roaming\\npm its above all, and make sure you are add current user directory.User ==> Path 的User variables下,确保C:\\Users\\user\\AppData\\Roaming\\npm最重要,并确保添加当前用户目录。

Note : If you don't have current user directory you have to create it.注意:如果您没有当前用户目录,则必须创建它。

在此处输入图片说明

3.Under System variables ==> Path , Make sure * C:\\Program Files\\nodejs* its above all. 3.在System variables ==> Path 下,确保 * C:\\Program Files\\nodejs*最重要。

在此处输入图片说明

  1. Open Command Prompt as user ==> npm cache clean --force .用户身份打开命令提示符==> npm cache clean --force
  2. npm install -g npm@lates t. npm install -g npm@lates t.
  3. ng new yourApp . ng 新的 yourApp
  4. ng serve --open . ng 服务 --open

are you working offline?你离线工作吗? you need to be online, so that npm can download the dependencies for the project.您需要在线,以便 npm 可以下载项目的依赖项。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM