mac系統下 html
通常來講 咱們默認安裝的 node.js 都是存在/usr/local/bin/node中 node
在Sublime的htmlprettify插件配置中 好比linux
{
// Simply using `node` without specifying a path sometimes doesn't work :(
// https://github.com/victorporof/Sublime-HTMLPrettify#oh-noez-command-not-found
// http://nodejs.org/#download
"node_path": {
//"windows": "C:/Program Files/nodejs/node.exe",
//"linux": "/usr/bin/nodejs",
"osx": "/usr/local/bin/node"
},
// Automatically format when a file is saved.
"format_on_save": false,
// Only format the selection if there's one available.
"format_selection_only": true,
// Log the settings passed to the prettifier from `.jsbeautifyrc`.
"print_diagnostics": true
}
1.在命令行中 運行node -v 肯定 node已經安裝成功,git
2.在命令行中 運行 which node 找到 node的所在目錄是否是和配置的同樣,若是不同則修改 配置文件中的路徑爲 which node 告知咱們的目錄github
3.可是咱們執行 prettycode(shift+comand+H)的時候仍是會出現 windows
Node.js was not found in the default path. Please specify the location.
4.有興趣的同窗能夠經過ctr+`去看Sublime 的運行日誌 裏面會說起到 測試
Unexpected error(<type 'exceptions.UnicodeEncodeError'>): 'ascii' codec can't encode characters in position 272-273: ordinal not in range(128)
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./HTMLPrettify.py", line 48, in run
File "./HTMLPrettify.py", line 124, in get_output_diagnostics
AttributeError: 'NoneType' object has no attribute 'find'
咱們能夠看得出來這個報錯信息和 HTMLprettify.py有關係.(沒興趣的同窗能夠不用管這個)spa
5.根據github 上得高人指出 這個是解碼問題 Sublime 這個插件不支持 utf-8 硬解 那麼咱們給他加encode("utf-8")即可插件
因此咱們直接去修改 HTMLprettify.py(記得先備份源文件)命令行
(1)找到HTMLprettify.py 通常都在 /Users/adfinitas42/Library/Application Support/Sublime Text 2/Packages/Sublime-HTMLPrettify/HTMLPrettify.py
(2) 84 行修改: PluginUtils.get_node_path() 成爲PluginUtils.get_node_path().encode("utf-8")
(3)86行 修改 file_path = self.view.file_name()成爲爲 tfile_path = self.view.file_name().encode("utf-8")
到此 問題就能解決(個人是mac 10.9.5 其餘的沒測試過)
順便附上
github 討論地址https://github.com/victorporof/Sublime-HTMLPrettify/issues/107