【问题标题】:Error while creating new project in angular以角度创建新项目时出错
【发布时间】:2019-05-07 19:31:47
【问题描述】:

我正在尝试使用命令 ng new my-app 创建新的 Angular 项目。下面列出了已安装的版本

  • Angular CLI:6.0
  • 节点版本:10.5.0
  • Npm : 6.1.0

我收到以下错误消息,

ERR! path D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts',
npm ERR!   parent: '@angular-devkit/build-optimizer' }
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).

【问题讨论】:

  • 您使用的是什么操作系统?对我来说似乎是窗口。是吗?
  • 我的机器在windows 10上运行
  • 您是否以管理员身份运行命令提示符?
  • 是的,我正在以管理员身份运行命令提示符。

标签: node.js angular npm


【解决方案1】:

临时修复,将 npm 降级到 5.3

npm install npm@5.3 -g

【讨论】:

    【解决方案2】:

    使用管理员权限。错误提示您没有使用管理员 CMD

    【讨论】:

      【解决方案3】:
      • 关闭代码编辑器后安装包,

      【讨论】:

        【解决方案4】:

        您是使用 Node Cmd 还是任何 IDE(如 VSCode)来创建新项目

        试试这个命令

        1. npm i -g @angular/cli
        2. ng 新的应用程序名称
        3. cd 应用程序名称。
        4. ng 服务

        【讨论】:

        • 如果你有 addl.关于问题的问题,将其发布为评论。不要发布不回答 OP 问题的答案
        • 我测试了相同的命令,它不起作用。检查我们是否使用 http npm 注册表而不是 https,您必须选择 https 。或者检查是否有防火墙
        猜你喜欢
        • 1970-01-01
        • 2020-12-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-11
        • 1970-01-01
        • 2023-03-04
        相关资源
        最近更新 更多