I am trying to use sublime-text 2, have installed Nodejs for Windows, the Nodejs plugin through package control and I get the following error:
ERROR: The process "node.exe" not found.
The filename, directory name, or volume label syntax is incorrect.
[Finished in 0.1s with exit code 1]
I have setup as my user environment variable a NODE_PATH: C:\Program Files\nodejs\node.exe
There is in my System variables PATH: C:\Program Files\nodejs\
My Nodejs.sublime-settings is set-up as follows:
{
// 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": false,
// as 'NODE_PATH' environment variable for node runtime
"node_path": "C:/Program Files/nodejs/node.exe",
"expert_mode": false,
"ouput_to_new_tab": false
}
My Nodejs.sublime-build is set-up as follows:
{
"cmd": ["C:/Program Files/nodejs/node.exe", "$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"]
}
}
As a side note, I'm using JSHint which uses Nodejs using the same path (namely "C:/Program Files/nodejs/node.exe") and JSHint works!
Any idea why I can't use Nodejs build system?
Thx
Try setting your build system just to the following for the time being:
{
"cmd": ["C:/Program Files/nodejs/node.exe", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
}
Because you have a Windows-specific section, it's running that instead of the "cmd" on the first line of the build system. I suspect there's some sort of issue with the taskkill command.
If this does work, and you feel the need to have the taskkill section back in there, try restructuring it like so:
"windows":
{
"cmd": ["taskkill", "/F", "/IM", "node.exe", "&", "C:/Program Files/nodejs/node.exe", "$file"],
"shell": true
}
Obviously, you don't need the linux section in there at all. I'm not too sure about the syntax on windows, you may need to have two ampersands && there instead of one - I know that's the case on OS X and Linux systems.
Good luck!
Related
I've been trying to build sublime text 3 for competitive programming and am getting confused about build systems. I've tried various build systems from the net and some start the console for i/o ,some show some error and don't work. I have downloaded MinGW as C:\MinGW\bin . I require a build which inputs from a file "input.txt" and outputs to "output.txt". Here is my sample code which I'm trying to run.
My code
What it does is open the console and even when I enter the input (present in the image), it doesn't give output.
The build -
{
"cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,
"variants":
[
{
"name": "Run",
"cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
"shell": true
}
] }
I have a project that uses a XML file of the type .uvprojx.
I have a sublime build I have found and modified slightly and it works fine but I can't get the build system to auto-detect that this is the build it needs to use. I need to manually go to Tools->Build systems -> My build.
This is my .sublime-build file:
{
"cmd": ["python", "C:/Users/cag/Documents/Tasks/PythonMisc/UvisionWrapper.py", "UV4", "-b", "-j0", "${file}", "-o", "out.txt"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.uvprojx",
"variants":
[
{
"name": "Flash",
"shell":true,
"cmd": ["python", "C:/Users/cag/Documents/Tasks/PythonMisc/UvisionWrapper.py", "UV4", "-f", "-j0", "${file}", "-o", "out.txt"]
},
{
"name": "Clean",
"shell":true,
"cmd": ["python", "C:/Users/cag/Documents/Tasks/PythonMisc/UvisionWrapper.py", "UV4", "-c", "-j0", "${file}", "-o", "out.txt"]
},
]
}
I have the python wrapper as the .exe file for the build creates a new process so I need to save the output to a file and read it in Python but anyway it works well.
What I want is that when I open a file with the extension .uvprojx this build is the default. If it matters Sublime detects this file as XML (which it is).
Change your selector to text.xml and add "file_patterns": ["*.uvprojx"], as per the documentation at http://www.sublimetext.com/docs/3/build_systems.html#options, then ST will auto-select the build system correctly for you.
What is the difference between args and runtimeArgs in launch.json?
// Optional arguments passed to the runtime executable
"runtimeArgs": []
// Command line arguments passed to the program
"args": []
Is the program not the same thing as the runtime executable?
Extra information and motivation behind the question:
I am developing a nodejs application. In my package.json, I have a start script:
"start": "electron ./src/Main/main.js arg2", and in my app code, I access process.argv[2] which gets me arg2, so when I run npm start, my app works as intended.
When I run the app from VSCode, however it doesn't, and the reason was that I wasn't supplying any additional arguments in launch.json. Where should I put those arguments? process.argv seems to contains the arguments provided in either args or runtimeArgs though it also sticks in some --debug-brk argument, which I don't want.
I want to be able to use process.argv consistently when I run the app from the command line (npm start) or start it from VSCode.
I think this is mostly explained in the Node debugging docs:
Instead of launching the Node.js program directly with node, you can use 'npm' scripts or other task runner tools directly from a launch configuration:
Any program available on the PATH (for example 'npm', 'mocha', 'gulp', etc.) can be used for the runtimeExecutable attribute [...]
runtimeExecutable is not the program you want to debug, but the executable used to run it. So it appears that runtimeArgs is to runtimeExecutable as args is to program.
If you're interested in how it works in detail, here's the relevant part of the debugAdapter.ts implementation.
If you remove the attribute "program", the arguments are attached after another and you don't see any difference.
Consider following example, including "type" and "program":
{
"name": "vscode-jest-tests",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest.js",
"stopOnEntry": false,
"args": [
"--runInBand"
],
"cwd": "${workspaceFolder}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
}
=> set "NODE_ENV=development" && "C:\Program Files\nodejs\node.exe" --nolazy --inspect-brk=35238 node_modules\jest-cli\bin\jest.js --runInBand
The runtimeArg "--nolazy" occurs behind node.exe (corresponds to type) and
The arg "--runInBand" occurs behind jest.js (corresonds to program)
If you remove the attribute "program", the arguments are attached after another and you don't see any difference.
I have VSCode 0.8 installed on windows 10, open to a folder. The grunt file at the root of this folder is named gruntfile.js (I also tried grunt.js). The grunt tasks work from the node cli but are not discovered inside VSCode.
I've tried ctrl+shift+p, then 'run task deploy-to-azure' where the task name in the grunt file is deploy-to-azure.
How is the grunt file auto-detected? Is there a way to turn on error reporting in VSCode or a log file I could review to see what is happening? Or perhaps an enumeration of all grunt, gulp, jake tasks?
Agreed I did this in .vscode/tasks.json and it all works OK for me. I did have to reboot because I lost grunt during the upgrade somehow.
// A task runner configuration.
{
"version": "0.1.0",
"command": "grunt",
"isShellCommand": true,
"tasks": [
{
"taskName": "build",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent"
// Use the standard less compilation problem matcher.
/* "problemMatcher": "$lessCompile" */
},
{
"taskName": "test",
// Make this the default build command.
"isBuildCommand": false,
// Show the output window only if unrecognized errors occur.
"showOutput": "always"
// Use the standard less compilation problem matcher.
/* "problemMatcher": "$lessCompile" */
},
{
"taskName": "localhost",
// Make this the default build command.
"isBuildCommand": false,
// Show the output window only if unrecognized errors occur.
"showOutput": "always"
// Use the standard less compilation problem matcher.
/* "problemMatcher": "$lessCompile" */
}
]
}
How would you run node app with sublime text? Like this, open the file app.js in sublime, go to menu->tools->build, and it just runs. Simple like that
Cmd+Shift+P , search for "Nodejs::Default File Settings" ,it will open file "Node.js.sublime-settings". you'll see:
{
// 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": false,
// Same for NPM command
"npm_command": false,
"expert_mode": false,
"ouput_to_new_tab": false
}
modify
"node_command": false,
to
"node_command": "/usr/local/bin/node",
if the node path is not the same with above, find it and change to yours.
If you want to fix the plugin's path yourself. One option is changing Nodejs.sublime-build. It's located in the packages directory of sublime:
Mac: ~/Library/Application Support/Sublime Text 2/Packages/Nodejs/Nodejs.sublime-build
Linux: ~/.config/sublime-text-2/Packages/Nodejs/Nodejs.sublime-build
Note: On latest OS X versions the Library folder is hidden. If that's the case, from the menu select Go > Go to Folder... and type ~/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"]
}
}
Lastly, open your *.js file and press command + b. Everything should just work fine now.
Linux Users: This file is identical across all operating systems. Finding the path to Nodejs.sublime-build may require running a search. In most cases it's located in ~/.config/sublime-text-2/Packages/Nodejs/Nodejs.sublime-build
To run nodejs on sublime text, install node package "node dev" then create a sublime text build, the code should look like this
{
"cmd": ["node-dev", "$file"],
"selector" : "source.js",
"path" : "/usr/local/bin"
}
Now to run a nodejs app, go to menu->tools->build.
What is going on is that you don't have the right PATH setup for your terminal.
try this command in a regular terminal:
> which node
I peronaly get this:
/usr/local/bin/node
As you can see this path is not in you environement path to add it in a regular terminal you would edit .bashrc or .bash_profile and add this line
export PATH=/usr/local/bin:$PATH
Here well you just have to look at the doc and find out that you need to modify the configuration file.
If you have a JavaScript file open, by selecting selecting Tools ->
Build Systems -> Nodejs and then hitting Ctrl + B, you will activate
the node build system on your file and node will try to run it. You
may need to add a path variable to the settings object for this if
your node executable is not found
Look at this.
On xubuntu, I made the build command in Nodejs.sublime-build explicity use the terminal:
"cmd": ["xfce4-terminal", "--command", "node $file"]
Create a build sytem with this code:
{
"cmd": ["node", "$file"],
"selector" : "source.js"
}
First make sure node is installed properly.
Create new build system in sublime.
Tools > Build System > New Build System
It will create new file. replace the content with below comman
{
"shell_cmd": "node $file"
}
save the file with extention .sublime-build
i.e. node.sublime-build
Now select build system in tools>build system>node (or whatever name you have set)
All set. open js file and hit ctrl+B or go Tools>build