Sublime Text 3: NodeJS build system terminates process (Windows) - node.js

So I have installed the Nodejs package and the .sublime-build file looks like this:
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell": false,
"encoding": "cp1252",
"windows":
{
"shell_cmd": "taskkill /F /IM node.exe & node $file"
},
...
}
And I have a basic JS file...
let check = true;
let funcToCheck = (check) => {
console.log(check);
}
funcToCheck();
The issue is whenever I try to build the JS file, I get:
SUCCESS: The process "node.exe" with PID 1308 has been terminated.
So it is terminating the process that has been created but is not actually logging anything to the console. I have looked at many examples on how the .sublime-build should look but cannot see where it is wrong

Related

Sublime Text Build System for Slim

If I type in the CMD.exe
slimrb -p SashaSlim.slim>SashaSlim.html
the contents of the my valid file, for example, SashaSlim.slim correct compiled into SashaSlim.html. But I can not make the build system for Sublime Text, which would do the same.
Example of my code:
{
"path": "$file_path",
"selector": "text.slim",
"shell_cmd": "slimrb -p $file_name>$file_base_name.html",
}
When I run my build system, create blank file SashaSlim.html without the result of compiling.
Where I made a mistakes in my .sublime-build file?
Windows 10
Sublime Text Build 3114
Thanks.
{
"cmd": ["slimrb"],
"working_dir": "${file_path:${folder}}",
"selector": "text.slim",
"quiet": true,
"windows": {
"cmd": ["slimrb", "-p", "--trace", "$file", "$file_base_name.html"],
"shell": true
}
}
Re: https://gist.github.com/Kristinita/f49eca1aa44545b5fcacaceeb8eaaee4

SublimeText build system for C/C++ in Terminal.

I am using "Linux Centos-7" and here I install "SublimeText-3".
C/C++ codes are running well in SublimeText Console but I want to run those code in Linux terminal.
I include a couple line in SublimeText build system like--
{
"shell_cmd": "g++ -std=c++11 \"${file}\" -o \"${file_path}/${file_base_name}.exe\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cpp",
"variants":
[
{
"name": "Run",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\""
}
]}
Above code is only create a executable file. which I have to run manually in terminal.
And,
{
"cmd": ["g++", "$file", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"variants":
[
{
"cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
"variants":
[
{
"name": "Run",
"shell": true,
"cmd": ["gnome-terminal -e 'bash -c \"${file_path}/${file_base_name};echo;echo; echo Press ENTER to continue; read line;exit; exec bash\"'"]
}
]
}
] }
This code can run only existing file in terminal.
Now, I just want to write code in SublimeText and execute it in terminal automatically.
Thanks.
I was in the same situation some days ago after I installed Sublime. I researched for a bit and ended up with this.
{
"cmd": ["g++", "-std=c++0x", "$file", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "g++ -std=c++0x '${file}' -o '${file_path}/${file_base_name}' && xterm -e bash -c '${file_path}/${file_base_name}; read'"]
}
]
}
You probably have to install xterm too.

Sublime Text3 console with nodemon

I can successfully use the node in the console of the sublime text 3 editor. I try to use nodemon to make it faster for me to run it each time I save the file.
I go tools-> build system and type this:
{
"cmd": [ "/usr/local/bin/nodemon", "$file" ],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js"
}
but I get the following error:
env: node: Argument list too long
[Finished in 25.7s with exit code 126]
[cmd: ['/usr/local/bin/nodemon', '/Users/x/Documents/MSCS/p2/v4/app.js']]
[dir: /Users/x/Documents/MSCS/p2/v4]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
And in the console here is what happens:
x$> nodemon --v app.js
env: node: Argument list too long
Thanks for help:)
Let me tell you how I manage
1st. add the main script on the package.json to start with a simple nodemon (without args)
"scripts": {
"start": "node app-server.js",
...
2nd. tools > build system > new build system
{
"shell": true,
"cmd": ["nodemon"],
"path": "/usr/local/bin/:$PATH",
"env": {
"dns_srv": "4.2.2.2",
},
"working_dir": "${project_path:${folder}}",
"selector": "*.js"
}
still working on how to get ansi colors on the output terminal..

Building node.js from sublime text (ERROR: The process "node.exe" not found.)

Step 1 : I installed node.js and used package control to install nodejs package for sublime.
Step 2 : Modified the sublime-settings to below
{
// save before running commands
"save_first": true,
// if present, use this command instead of plain "node"
// e.g. "/usr/bin/node" or "C:\bin\node.exe"
"node_command": "\"C:/Program Files/nodejs/node.exe\"",
// Same for NPM command
"npm_command": "\"C:/Program Files/nodejs/npm\"",
// as 'NODE_PATH' environment variable for node runtime
"node_path": "\"C:/Program Files/nodejs/node.exe\"",
"expert_mode": false,
"ouput_to_new_tab": false
}
Step 3 : I created a simple js file with console.log("Hello World");
When tried to build using Tools -> Build, It does print Hello World in the console, but also gives me the error
ERROR: The process "node.exe" not found.
Any help would be really appreciated as to why I'm getting this.
Thanks.
EDIT : I was able to fix it by removing the following from nodejs.sublime-build
"windows": { "cmd": ["taskkill /F /IM node.exe & node", "$file"] }, "linux": { "cmd": ["killall node; node", "$file"] }
On windows, instead of removing this line from nodejs.sublime-build
"windows": { "cmd": ["taskkill /F /IM node.exe & node", "$file"] }...
you can replace with
"windows": { "cmd": ["taskkill /F /IM node.exe & node 2>null", "$file"] }...
this allows to redirect the annoying error message of the TASKILL command to null.
On windows, apply absolute path of node.exe installation folder in nodejs.sublime-build file as follows:
"windows": {"cmd": ["C:/Program Files/nodejs/node.exe", "$file"]} ...

NodeJS Sublime Text Build System

I've installed Sublime Text's NodeJS plugin which provides a NodeJS build that looks like this:
{
"cmd": ["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"]
}
}
I've compiled node myself and located into: /opt/node/v0.10.24. The full path to the bin being /opt/node/v0.10.24/bin/node.
I'm testing this with a simple file containing console.log('Hello World');
When running the build system I get:
/Users/jviotti/Desktop/test.js: node: command not found
[Finished in 0.0s with exit code 127]
I tried adding a path to the build like this:
"path": "/opt/node/v0.10.24/bin",
And when running the build I get just:
[Finished in 0.1s]
Notice that the console log is not printed. What am I missing?
EDIT: This is the NodeJS plugin I use: https://github.com/tanepiper/SublimeText-Nodejs
This should do it ..
{
"cmd": ["node $file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell": false,
"encoding": "cp1252",
"windows":
{
"cmd": ["taskkill /F /IM node.exe && node $file"]
},
"linux":
{
"cmd": ["killall nodejs 2>/dev/null; nodejs $file"] // or node, if built from source
}
}
Found the problem. Commenting out "shell": true solves the problem.

Resources