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

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"]} ...

Related

Sublime Text 3: NodeJS build system terminates process (Windows)

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

VSCode/Win10 - Cannot find runtime 'node' on PATH

To reproduce:
Use my Windows 10 PC to open VSCode
Create a Hello World js file
Launch as node application from the VSCode Debugger view
Produces error: Cannot find runtime 'node' on PATH
Given:
My launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Build",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/build.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": false
}
]
}
I have moved nodejs to within 2048 characters of my PATH variable.
I have restarted my computer.
I have restarted VSCode.
From both CMD and the Integrated Terminal (sysnative/cmd):
PATH contains D:/Program Files/nodejs
where node returns D:/Program Files/nodejs/node.exe
From the Google Developer Console:
process.env.PATH contains D:/Program Files/nodejs
Running the following code produces D:/Program Files/nodejs/node.exe:
(function(){
const cp = require('child_process');
const env = Object.assign({}, process.env, {
ATOM_SHELL_INTERNAL_RUN_AS_NODE: '1',
ELECTRON_NO_ATTACH_CONSOLE: '1'
});
const result = cp.spawnSync('where', ['node'], {
detached: true,
stdio: ['ignore', 'pipe', process.stderr],
env,
encoding: 'utf8'
});
console.log(result.stdout);
})();
Additional
Also .NET-Core applications behave identically - terminal and cmd works, dotnet is on the path, but Launch from VSCode debugger view fails to find CLI Tools on the path.
Attaching to an existing dotnet process produces a different error:
Please set up the launch configuration file for your application. command 'csharp.listProcess' not found
Not sure if related, but F12 for jumping to declaration is unresponsive.
Update
I've been doing some debugging, and it looks like the following code produces Command Failed: echo test:
require('child_process')
.execSync('echo test', {cwd: workspaceRoot, env: process.env});
Under the hood, it winds up calling
require('child_process')
.spawnSync('cmd', ['/s', '/c', '"echo test"'], {cwd: workspaceRoot, env: process.env});
The command it builds under the hood is C:\Windows\System32\cmd.exe /s /c "echo test" which I tested and does indeed print test.
The spawnSync call reveals that the exit code was 3221225477.
In fact, every time I use child_process to execute something via cmd, the exit code is 3221225477. I can get spawnSync to start other processes aside from cmd, though. This works:
require('child_process')
.spawnSync('node', ['build.js'], {cwd: workspaceRoot, env: process.env});

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

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..

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