在angular中创建新项目时出错

时间:2018-07-10 12:52:01

标签: node.js angular npm

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

  • 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).

3 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

临时修复程序,将npm降级到5.3

npm install npm@5.3 -g

答案 2 :(得分:-3)

您是否使用Node Cmd或任何IDE(例如VSCode)创建新项目

尝试此命令

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