【问题标题】:Creating an Angular Project with NG NEW Never Works These Days - Ends in error code EPERM使用 NG NEW 创建 Angular 项目这些天从来没有用过 - 以错误代码 EPERM 结尾
【发布时间】:2020-03-08 23:17:49
【问题描述】:

如果错误或错误看起来如此猖獗并且可以持续很长时间而没有任何记录在案的解决方法,那么 Angular 是否不再是一个严肃的框架?

....
24695 silly saveTree | +-- builtin-modules@1.1.1
24695 silly saveTree | +-- semver@5.7.1
24695 silly saveTree | `-- tsutils@2.29.0
24695 silly saveTree +-- typescript@3.5.3
24695 silly saveTree `-- zone.js@0.9.1
24696 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\karma\node_modules\fsevents):
24697 warn enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'D:\wamp64\www\SALES-IMS\node_modules\.staging\fsevents-25de8bdf\node_modules\abbrev' -> 'D:\wamp64\www\SALES-IMS\node_modules\.staging\abbrev-5ccfe549'
24698 verbose enoent SKIPPING OPTIONAL DEPENDENCY: This is related to npm not being able to find a file.
24698 verbose enoent SKIPPING OPTIONAL DEPENDENCY:
24699 verbose stack Error: EPERM: operation not permitted, unlink 'D:\wamp64\www\SALES-IMS\node_modules\.staging\typescript-4e9060a8\lib\tsserver.js'
24700 verbose cwd D:\wamp64\www\SALES-IMS
24701 verbose Windows_NT 10.0.17134
24702 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"
24703 verbose node v12.11.1
24704 verbose npm  v6.11.3
24705 error code EPERM
24706 error syscall unlink
24707 error path D:\wamp64\www\SALES-IMS\node_modules\.staging\typescript-4e9060a8\lib\tsserver.js
24708 error errno -4048
24709 error Error: EPERM: operation not permitted, unlink 'D:\wamp64\www\SALES-IMS\node_modules\.staging\typescript-4e9060a8\lib\tsserver.js'
24709 error  [OperationalError: EPERM: operation not permitted, unlink 'D:\wamp64\www\SALES-IMS\node_modules\.staging\typescript-4e9060a8\lib\tsserver.js'] {
24709 error   cause: [Error: EPERM: operation not permitted, unlink 'D:\wamp64\www\SALES-IMS\node_modules\.staging\typescript-4e9060a8\lib\tsserver.js'] {
24709 error     errno: -4048,
24709 error     code: 'EPERM',
24709 error     syscall: 'unlink',
24709 error     path: 'D:\\wamp64\\www\\SALES-IMS\\node_modules\\.staging\\typescript-4e9060a8\\lib\\tsserver.js'
24709 error   },
24709 error   stack: "Error: EPERM: operation not permitted, unlink 'D:\\wamp64\\www\\SALES-IMS\\node_modules\\.staging\\typescript-4e9060a8\\lib\\tsserver.js'",
24709 error   errno: -4048,
24709 error   code: 'EPERM',
24709 error   syscall: 'unlink',
24709 error   path: 'D:\\wamp64\\www\\SALES-IMS\\node_modules\\.staging\\typescript-4e9060a8\\lib\\tsserver.js',
24709 error   parent: 'SALES-IMS'
24709 error }
24710 error The operation was rejected by your operating system.
24710 error It's possible that the file was already in use (by a text editor or antivirus),
24710 error or that you lack permissions to access it.
24710 error
24710 error If you believe this might be a permissions issue, please double-check the
24710 error permissions of the file and its containing directories, or try running
24710 error the command again as root/Administrator.
24711 verbose exit [ -4048, true ]

我尝试了以下方法无济于事。

  • 我已禁用防病毒和
  • 多次重复安装,
  • 重启我的机器,
  • 确保 VS Studio Code 已关闭...,
  • 运行npm cache clean,然后运行npm cache clean --force,手动删除两个npm %APPDATA% 路径下的缓存和 npm 文件夹,然后重新安装 角度与npm install -g @angular/cli

都是相同的 EPERM 错误,...不同的文件但相同的 errno -4048。

我在硬盘上有足够 GB 的可用空间,权限也没有什么特别之处。我是 Windows 10 笔记本电脑的管理员。每个 CMD 指令都以管理员身份运行。已经连续数周了,在网上尝试了各种建议......但没有看到任何解决方案。

最后,有没有办法解决这个问题?还是我只是因为 Angular 是一个不可靠、不可用的框架而放弃?

【问题讨论】:

  • 这可能不是因为 Angular 是一个“垃圾”或“不可靠且不可用”的框架,而是由于您的文件系统或程序打开导致安装无法继续。
  • 顺便说一句,你似乎在一个月前提出了一个类似的问题:stackoverflow.com/questions/58334156/…
  • @Edric 我听到了,但是绝对没有任何程序打开相关文件的实例...我直接从重新启动中获得...没有打开 Node.js 进程,没有编辑器打开,杀毒软件被禁用。我认为问题实际上可能出在 Node.js... 而不是 Angular 本身。
  • 可能是因为您使用 sudo 访问权限运行命令?这可能会弄乱文件权限。

标签: node.js angular windows npm


【解决方案1】:

这与 Angular 本身没有任何关系,但与您的 NodeJS 安装和 npm 有关。第一步是确保没有真正的权限问题。

我在为现有的 Angular 7 项目运行 npm install 几个星期以来一直面临相同和类似的错误。最终决定从 npm 切换到 yarn,从那时起一切正常。在 npm 出现不一致和随机错误让我烦恼了好几个星期之后,切换到 yarn 作为包管理器对我来说是一个诀窍。

也许降级到较旧的 npm 版本(~5.3.0)也可以解决这个问题。

【讨论】:

  • 不幸的是,我无法降级或使用纱线。我需要 npm 和 Node.js 的最新功能,因为我还使用 Expo 来完成我在 React Native 中的工作。
【解决方案2】:

我终于找到了解决办法。也就是说,要安装失败的包,每次使用npm install package --force

例如,在我的例子中是npm install -g @angular/core@~8.2.13 --forcenpm install -g typescript@~3.5.3 --force

然后我像以前一样重复ng new project-name 命令。它现在可以成功运行。

没有其他任何建议有效,在我的情况下。

非常感谢!

【讨论】:

  • 人们可能忽略了这个解决方案,但自从我发现它以来,它解决了我每次安装失败的问题!
猜你喜欢
  • 2021-08-11
  • 2018-08-28
  • 2018-04-19
  • 2017-07-24
  • 2018-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-28
相关资源
最近更新 更多