0%

MacBook Pro 入手安裝紀錄

衣服和褲子總要穿穿才會合身,何況是電腦這麼神聖的東西。

這篇是很久以前紀錄的,如果 2019 年八月買的,到現在也已經七個月了,但是很神奇的是,從舊電腦換到新電腦,幾乎是有種無痛轉移的狀態,雖然是新電腦,但其實頗懷念舊的。

上一台舊的 MacBook Pro 是已經停產的 17 吋筆電,很重但很好用,我用她做所有的事情,且從 2001 年入手到換新電腦,她都很良善的陪著我,隨然中後期她的一邊喇吧不再動了,但是除此之外一切都很完美,直到近一兩年,安裝新的系統,對她而言開始覺得很吃力,負荷不過來,所以才有想要換新電腦的念頭。

原本以為寫程式是不太需要記憶體或空間的,但是學了才知道,要安裝一大堆的編譯器和套件,也頗重的。尤其套件從網站上下載下來,有時會達到幾百 M ,這時她就會氣喘如牛了。但是一台筆電陪了我近九年,也真的是算辛苦了,希望新的 MacBook Pro 也可以陪我長長久久,而我也會很珍惜與保護她的。

由於在法國買的鍵盤超難打 code ,所以就決定回來台灣買。入手的時候在好想工作室 trining,所以也就得到許多人的幫助與建議,且還把部落格給架了起來。以前架站都是用 Wordpress,這次安裝在 github 上倍感新鮮。

安裝 Hexo 紀錄

而在本機安裝 hexo 使npm install -g hexo-cli卻發現權限不足的問題,記得 Chris 說過,盡量不要用sudo這個最高權限安裝,所以來找一下其他方式,找到這篇:npm install -g less does not work 裡面也說盡量不要用sudo安裝,所以想來仔細了解一下。

此篇寫著: Using sudo is not recommended. It may give you permission issue later. While the above works, I am not a fan of changing folders owned by root to be writable for users, although it may only be an issue with multiple users. To work around that, you could use a group, with ‘npm users’ but that is also more administrative overhead. See here for the options to deal with permissions from the documentation: https://docs.npmjs.com/getting-started/fixing-npm-permissions

所以他用以下的方法:
I would go for option 2:

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, it will be a hidden directory on your home folder. 要最小化權限錯誤的可能性,可以將 npm 配置為使用其他目錄。在此示例中,它將是主文件夾中的隱藏目錄。

Make a directory for global installations:
為全局安裝創建一個目錄:
mkdir ~/.npm-global

Configure npm to use the new directory path:
配置 npm 以使用新的目錄路徑:
npm config set prefix '~/.npm-global'

Open or create a /.profile file and add this line:
打開或創建一個〜/ .profile 文件並添加以下行:
`export PATH=
/.npm-global/bin:$PATH`
Ps.發現自己有一個.bash_profile 所以就把以上這行存在.bash_profile,就解決了。

Back on the command line, update your system variables:
返回命令行,更新系統變量:
source ~/.profile

Test: Download a package globally without using sudo.
測試:在不使用 sudo 的情況下全局下載軟件包。
npm install -g jshint
==有試成功 安裝 hexo OK 但要用 hexo 時又不行==

If still show permission error run (mac os):
如果仍顯示權限錯誤運行(mac os):
sudo chown -R $USER ~/.npm-global

This works with the default ubuntu install of:
這適用於默認的 ubuntu 安裝:==(oz:表示還是用 sodu 吧…)==
sudo apt-get install nodejs npm

I recommend nvm if you want more flexibility in managing versions: https://github.com/creationix/nvm
如果您想要更靈活地管理版本,我建議使用 nvm:

On MacOS use brew, it should work without sudo out of the box if you’re on a recent npm version. Enjoy :)
在 MacOS 上使用 brew,如果您使用的是最近的 npm 版本,它應該可以在沒有開箱即用的情況下使用。請享用 :)

幾個開發工具介紹

brew : MacOs 主要的套件管理工具 (The missing package manager for macOS)。用來補足 macOS 所欠缺的套件管理工具。
官網 | 介紹

NPM 是隨同 NodeJS 一起安裝的包管理工具,能解決 NodeJS 程式碼部署上的很多問題。
官網 | 套件管理 & 常用開發工具介紹

Node Version Manager 是 Node.js 版本管理的工具。
照官網安裝後,仍要去 .bash_profile 改路徑與環境變數。
官網教學

Mac 的環境變數相關文章
Mac 環境變數小記