node. js path problem and solution sublime Text2 under Mac system

Source: Internet
Author: User
Tags sublime text

Under Mac System

In general, the node. js that we install by default is present in/usr/local/bin/node

In Sublime's htmlprettify plug-in configuration, for example,

{
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. Run node-v on the command line to make sure that node is installed successfully,


2. Run which node in the command line if the directory where node is located is not the same as the configuration, if it is not the same, modify the path in the configuration file to which node tell us the directory


3. But when we execute Prettycode (shift+comand+h), it still appears.

node. JS is not found in the default path. Specify the location.


4. Interested students can go through the ctr+ ' to see the sublime of the running log will be mentioned in the

Unexpected error (<type ' exceptions. Unicodeencodeerror ' >): ' ASCII ' codec can ' t encode characters in position 272-273:ordinal not in range (128)
Traceback (most recent):
File "./sublime_plugin.py", line 362, in Run_
File "./htmlprettify.py", line +, in run
File "./htmlprettify.py", line 124, in Get_output_diagnostics
Attributeerror: ' Nonetype ' object has no attribute ' find '

We can see that this error message has something to do with htmlprettify.py. (Students who are not interested can take care of this)


5. According to the GitHub expert pointed out that this is a decoding problem Sublime this plugin does not support utf-8 hard solution so we give him encode ("Utf-8") can

So we go directly to modify htmlprettify.py (remember to back up the source file first)

(1) Find htmlprettify.py generally in /users/adfinitas42/library/application support/sublime Text 2/PACKAGES/SUBLIME-HTMLPR ettify/htmlprettify.py


(2) 84 lines modified: Pluginutils.get_node_path () becomes Pluginutils.get_node_path (). Encode ("Utf-8")


(3) 86 line Modify File_path = Self.view.file_name () becomes tfile_path = Self.view.file_name (). Encode ("Utf-8")

This problem can be solved (my Mac 10.9.5 other not tested)



Incidentally attached

GitHub Discussion Address https://github.com/victorporof/Sublime-HTMLPrettify/issues/107



node. js path problem and solution sublime Text2 under Mac system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.