Angular 8:当我尝试ng服务时出现internal / modules / cjs / loader.js错误

时间:2019-08-28 04:22:03

标签: node.js angular npm-install

当我克隆角度项目并运行“ npm install”以在node_module中安装所有依赖项时,我会遇到此错误:

npm ERR! path D:\Project\VipUi\angular\node_modules\.staging\echarts-25586c04\map\js\world.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'D:\Project\VipUi\angular\node_modules\.staging\echarts-25586c04\map\js\world.js'
npm ERR!  { [Error: EPERM: operation not permitted, lstat 'D:\Project\VipUi\angular\node_modules\.staging\echarts-25586c04\map\js\world.js']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, lstat 'D:\Project\VipUi\angular\node_modules\.staging\echarts-25586c04\map\js\world.js'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'lstat',
npm ERR!      path:
npm ERR!       'D:\\Project\\VipUi\\angular\\node_modules\\.staging\\echarts-25586c04\\map\\js\\world.js' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, lstat \'D:\\Project\\VipUi\\angular\\node_modules\\.staging\\echarts-25586c04\\map\\js\\world.js\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path:
npm ERR!    'D:\\Project\\VipUi\\angular\\node_modules\\.staging\\echarts-25586c04\\map\\js\\world.js',
npm ERR!   parent: 'angular' }
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).

然后我尝试获取队友的node_module并将其复制到我的项目中,我在Powershell中收到loader.js错误

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module 'D:\Project\VipUi\angular\node_modules\@angular\cli\bin\ng'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

如何解决此问题?

1 个答案:

答案 0 :(得分:0)

  

npm - EPERM: operation not permitted on Windows

  1. 以管理员身份运行cmd

  2. 运行npm config edit(您将获得记事本     编辑器)

  3. 将前缀变量更改为C:\ Users \\ AppData \ Roaming \ npm