macOS安裝Angular及安裝失敗問題排查

安裝node.js

推薦使用Homebrew安裝node.js:
brew install node

筆者這里使用官網(wǎng)pkg安裝出了點問題省艳,卸載時就很麻煩了,卸載pkg安裝的node.js參考鏈接:
How to Uninstall Node.js from Mac OSX

完成安裝之后檢查是否成功安裝:

kidneybro@macbookPro:~$ node -v
v11.10.0
kidneybro@macbookPro:~$ npm -v
6.7.0
kidneybro@macbookPro:~$ which npm
/usr/local/bin/npm
kidneybro@macbookPro:~$ which node
/usr/local/bin/node

安裝angular

使用cli命令安裝:
npm install -g @angular/cli

問題排查

筆者因為第一次安裝的時候出現(xiàn)問題缓呛,問題報錯整理如下:

kidneybro@macbookPro:~$ npm install -g @angular/cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@angular/cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@angular/cli/node_modules
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@angular
npm ERR! path /usr/local/lib/node_modules/@angular/cli
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@angular/cli'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@angular/cli']
npm ERR!   stack:
npm ERR!    "Error: EACCES: permission denied, access '/usr/local/lib/node_modules/@angular/cli'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/@angular/cli' }
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/xuhaoshen/.npm/_logs/2019-02-26T02_28_55_578Z-debug.log

定位問題:
cd進入目錄/usr/local/lib/node_modules/

kidneybro@macbookPro:~$ ll /usr/local/lib/node_modules
total 0
drwxr-xr-x   4 xuhaoshen  admin  128  2 25 22:16 .
drwxr-xr-x  26 xuhaoshen  admin  832  2 25 22:15 ..
drwxr-xr-x   3 root       admin   96  2 25 22:16 @angular
drwxr-xr-x  25 xuhaoshen  admin  800  2 25 22:13 npm

@angular目錄的創(chuàng)建者是root,故沒有權(quán)限操作,安裝失敗,刪除當(dāng)前@angular目錄即可盐肃,之后重新運行安裝指令有

kidneybro@macbookPro:~$ npm install -g @angular/cli
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng

> fsevents@1.2.7 install /usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download
[fsevents] Success: "/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" is installed via remote
+ @angular/cli@7.3.3
added 363 packages from 196 contributors in 7.638s

最終安裝成功

Angular使用Tutorial

Angualr QuickStart

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市权悟,隨后出現(xiàn)的幾起案子砸王,更是在濱河造成了極大的恐慌,老刑警劉巖峦阁,帶你破解...
    沈念sama閱讀 218,858評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件谦铃,死亡現(xiàn)場離奇詭異,居然都是意外死亡榔昔,警方通過查閱死者的電腦和手機驹闰,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,372評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來撒会,“玉大人嘹朗,你說我怎么就攤上這事∷懈兀” “怎么了屹培?”我有些...
    開封第一講書人閱讀 165,282評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長怔檩。 經(jīng)常有香客問我褪秀,道長,這世上最難降的妖魔是什么薛训? 我笑而不...
    開封第一講書人閱讀 58,842評論 1 295
  • 正文 為了忘掉前任媒吗,我火速辦了婚禮,結(jié)果婚禮上许蓖,老公的妹妹穿的比我還像新娘蝴猪。我一直安慰自己调衰,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,857評論 6 392
  • 文/花漫 我一把揭開白布自阱。 她就那樣靜靜地躺著嚎莉,像睡著了一般。 火紅的嫁衣襯著肌膚如雪沛豌。 梳的紋絲不亂的頭發(fā)上趋箩,一...
    開封第一講書人閱讀 51,679評論 1 305
  • 那天,我揣著相機與錄音加派,去河邊找鬼叫确。 笑死,一個胖子當(dāng)著我的面吹牛芍锦,可吹牛的內(nèi)容都是我干的竹勉。 我是一名探鬼主播,決...
    沈念sama閱讀 40,406評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼娄琉,長吁一口氣:“原來是場噩夢啊……” “哼次乓!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起孽水,我...
    開封第一講書人閱讀 39,311評論 0 276
  • 序言:老撾萬榮一對情侶失蹤票腰,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后女气,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體杏慰,經(jīng)...
    沈念sama閱讀 45,767評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,945評論 3 336
  • 正文 我和宋清朗相戀三年炼鞠,在試婚紗的時候發(fā)現(xiàn)自己被綠了缘滥。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,090評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡簇搅,死狀恐怖完域,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情瘩将,我是刑警寧澤吟税,帶...
    沈念sama閱讀 35,785評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站姿现,受9級特大地震影響肠仪,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜备典,卻給世界環(huán)境...
    茶點故事閱讀 41,420評論 3 331
  • 文/蒙蒙 一异旧、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧提佣,春花似錦吮蛹、人聲如沸荤崇。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,988評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽术荤。三九已至,卻和暖如春每篷,著一層夾襖步出監(jiān)牢的瞬間瓣戚,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,101評論 1 271
  • 我被黑心中介騙來泰國打工焦读, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留子库,地道東北人。 一個月前我還...
    沈念sama閱讀 48,298評論 3 372
  • 正文 我出身青樓矗晃,卻偏偏與公主長得像仑嗅,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子喧兄,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,033評論 2 355

推薦閱讀更多精彩內(nèi)容