簡體   English   中英

Mac 無法安裝 Angular-CLI

[英]Mac can't install Angular-CLI

我正在嘗試安裝 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,我寫的是 Yes。 然后我得到這些錯誤。

[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.

如果這里有人遇到和我一樣的問題,基本上我所做的就是跑

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

在我的終端中,然后我重新啟動了我的電腦。 一旦我這樣做了,我基本上只是創建了一個新項目,然后從那里添加了所有內容(包括 Angular CLI)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM