【问题标题】:Mac can't install Angular-CLIMac 无法安装 Angular-CLI
【发布时间】:2019-10-17 05:57:27
【问题描述】:

我正在尝试安装 Angular-CLI,以便我可以使用 Ionic 框架,但是安装不断崩溃并给我这样的错误。

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
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).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2019-05-31T09_00_09_770Z-debug.log

我试过通过写来安装它

sudo npm install -g @angular-cli

我也尝试通过这里的方法安装它: Can't install angular-cli on Mac

抱歉,我对这方面还很陌生,所以我不确定我应该提供什么信息。

我已经安装了 Node JS (10.16.0)

我还刚刚安装了 Ionic Framework 和 Cordova,但是每当我尝试打开通过终端创建的项目时,它都会告诉我需要安装 Angular-CLI,一旦我同意安装,我收到与上述相同的错误。

我的 MacOSX 是 10.14.5

编辑:

我已为当前用户在我的计算机上登录分配了读写权限,但我仍然遇到错误。当我在终端中运行Ionic lab 以打开我的项目时,终端会询问我是否要安装 Angular,我写的是“是”。然后我得到这些错误。

[ng] Could not find module "@angular-devkit/build-angular" from "/Users/me/project".
[ng] Error: Could not find module "@angular-devkit/build-angular" from "/Users/me/project".
[ng]     at Object.resolve (/Users/me/project/node_modules/@angular-devkit/core/node/resolve.js:141:11)
[ng]     at Observable.rxjs_1.Observable [as _subscribe] (/Users/me/project/node_modules/@angular-devkit/architect/src/architect-legacy.js:153:40)
[ng]     at Observable._trySubscribe (/Users/me/project/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:44:25)
[ng]     at Observable.subscribe (/Users/me/project/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:30:22)
[ng]     at /Users/me/project/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:99:19
[ng]     at new Promise (<anonymous>)
[ng]     at Observable.toPromise (/Users/me/project/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:97:16)
[ng]     at RunCommand.runSingleTarget (/Users/me/project/node_modules/@angular/cli/models/architect-command.js:161:86)
[ng]     at RunCommand.runArchitectTarget (/Users/me/project/node_modules/@angular/cli/models/architect-command.js:201:35)
[ng]     at RunCommand.run (/Users/me/project/node_modules/@angular/cli/commands/run-impl.js:14:25)
[ng]     at RunCommand.validateAndRun (/Users/me/project/node_modules/@angular/cli/models/command.js:124:31)
[ng]     at process._tickCallback (internal/process/next_tick.js:68:7)
[ng]     at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
[ng]     at startup (internal/bootstrap/node.js:283:19)
[ng]     at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

[ERROR] ng has unexpectedly closed (exit code 1).

        The Ionic CLI will exit. Please check any output above for error
        details.

【问题讨论】:

  • 将读写权限分配给 /usr/local/lib/node_modules 目录,然后再试一次,(google how to)
  • @Ejaz47 我仍然收到错误消息。我已经编辑了我的问题,所以你可以看到我遇到了什么类型的错误。请帮忙
  • @Ejaz47 多亏了你,我想我已经明白了!感谢您的帮助!

标签: node.js macos ionic-framework angular-cli


【解决方案1】:

如果这里有人遇到和我一样的问题,基本上我所做的就是我跑了

sudo chown -R $(whoami) ~/.npm*

在我的终端中,然后我重新启动了计算机。一旦我这样做了,我基本上只是创建了一个新项目并从那里添加了所有内容(包括 Angular CLI)

【讨论】:

    猜你喜欢
    • 2018-06-23
    • 2017-07-08
    • 2017-01-31
    • 2018-08-06
    • 2017-08-22
    • 2017-03-23
    • 2019-10-24
    相关资源
    最近更新 更多