【问题标题】:Angular 8: Getting internal/modules/cjs/loader.js error when i try to ng serveAngular 8:当我尝试 ng 服务时出现 internal/modules/cjs/loader.js 错误
【发布时间】:2020-03-28 00:32:09
【问题描述】:

当我克隆我的 Angular 项目并运行“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)

我该如何解决这个问题?

【问题讨论】:

    标签: node.js angular npm-install


    【解决方案1】:

    npm - EPERM: operation not permitted on Windows

    1. 以管理员身份运行 cmd

    2. 运行 npm config edit(你会得到记事本 编辑)

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

    【讨论】:

    • 用于安装节点模块
    • C:\Users\AppData\Roaming\npm 就是这样
    • C:\Users\Karim\AppData\Roaming\npm 我添加了这个
    • 我能知道你的 npm 版本吗
    猜你喜欢
    • 2021-11-18
    • 2021-03-21
    • 2020-01-20
    • 2020-07-03
    • 2019-12-28
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    相关资源
    最近更新 更多