How to run node application with exalted text

How would you launch a node application with sublime text? So, open the app.js file in a sublime view, go to menu-> tools-> build, and it just starts. Simple like this

+6
source share
5 answers

To run nodejs on exalted text, install the node package "node dev", then create an exalted text assembly, the code should look like this:

{ "cmd": ["node-dev", "$file"], "selector" : "source.js", "path" : "/usr/local/bin" } 

Now, to start the nodejs application, go to menu-> tools-> build.

+4
source

Cmd + Shift + P, find "Nodejs :: Default File Settings", it will open the file "Node.js.sublime-settings". you will see:

 { // save before running commands "save_first": true, // if present, use this command instead of plain "node" // eg "/usr/bin/node" or "C:\bin\node.exe" "node_command": false, // Same for NPM command "npm_command": false, "expert_mode": false, "ouput_to_new_tab": false } 

change

"node_command": false,

to

"node_command": "/ usr / local / bin / node",

If the node path does not match the previous one, find it and change it to yours.

+18
source

If you want to fix the plugin path yourself. One option is to modify Nodejs.sublime-build. It is located in the sublime package directory:

 Mac: ~/Library/Application Support/Sublime Text 2/Packages/Nodejs/Nodejs.sublime-build Linux: ~/.config/sublime-text-2/Packages/Nodejs/Nodejs.sublime-build 

Note. In recent versions of OS X, the library folder is hidden. If in this case, select "Go"> "Go to Folder ..." from the menu and enter ~ / Library.

 Change "cmd": ["node", "$file"] to "cmd": ["/usr/local/bin/node", "$file"] { "cmd": ["/usr/local/bin/node", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.js", "shell":true, "encoding": "cp1252", "windows": { "cmd": ["taskkill /F /IM node.exe & node", "$file"] }, "linux": { "cmd": ["killall node; node", "$file"] } } 

Finally, open the * .js file and press the + b command. Now everything should work fine.

Linux users: this file is identical on all operating systems. Finding a path to Nodejs.sublime-build may require a search. In most cases, it is located in ~ / .config / sublime-text-2 / Packages / Nodejs / Nodejs.sublime-build

+6
source

What happens is that you do not have a suitable PATH setting for your terminal.

try this command in a regular terminal:

 > which node 

I get the following:

 /usr/local/bin/node 

As you can see, this path is not in your environement path, to add it to a regular terminal, you must edit .bashrc or .bash_profile and add this line

 export PATH=/usr/local/bin:$PATH 

Here you just need to look at the doc and find out that you need to change the configuration file.

If you have a JavaScript file open by choosing Tools β†’ Build Systems β†’ Nodejs and then pressing Ctrl + B, you activate the node build system in your file and node tries to run it. You may need to add a path variable to the settings object for this if your node executable is not found

Take a look at this one .

+1
source

On xubuntu, I made the build command in Nodejs.sublime-build explicity using the terminal:

"cmd": ["xfce4-terminal", "--command", "node $ file"]

0
source

Source: https://habr.com/ru/post/923746/


All Articles