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..
Related
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
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
I can compile and run my JSX app with one command:
jsx app.jsx | node
But I also want my server to automatically restart every time I modify app.jsx. I can do that with nodemon, but I can't quite figure out how to get nodemon to run my script through the JSX compiler beforehand.
I've got a nodemon.json file set up like this:
{
"execMap": {
"js": "node",
"jsx": "jsx {{filename}} | node"
},
"ext": "js jsx",
"ignore": [
".hg",
"node_modules",
".idea"
],
"verbose": true
}
But when I run nodemon it tells me:
8 Feb 21:58:48 - [nodemon] starting `jsx app.jsx | node`
8 Feb 21:58:48 - [nodemon] child pid: 10976
'\"jsx app.jsx | node\"' is not recognized as an internal or external command,
operable program or batch file.
Which is odd, because that command works verbatim when I paste it directly into my terminal.
Is there any way I get nodemon to run my JSX files?
It seems nodemon is attempting to run a program with the name you provide, rather than executing a shell.
Create a jsx.sh file with this content:
#!/bin/sh
jsx "$1" | node
Then chmod +x jsx.sh, and put this in your nodemon.json:
{
"execMap": {
"js": "node",
"jsx": "./jsx.sh"
},
"ext": "js jsx",
"ignore": [
".hg",
"node_modules",
".idea"
],
"verbose": true
}
* not tested
OR you can just locate the jsx command in your ./node_modules/.bin directory and run it off that instead:
{
script: "client.js",
options: {
execMap: {
"js": "node",
"jsx": "./node_modules/.bin/jsx \"$1\" | node"
},
ext: "js jsx",
callback: function (nodemon) {
nodemon.on("log", function (event) {
console.log(event.colour);
});
},
ignore: [
"node_modules/**/*.js",
"public/js/**",
"lib/api/**",
]
}
}
If you're on Windows (like me) you can create a .bat instead of a .sh like FakeRainBrigand suggests
#echo off
jsx %1 | node
This file has to be in the same directory as nodemon.json and package.json -- paths don't seem to work in the execMap for whatever reason.
Also, an even easier solution is to just not use any JSX in your main/server script, install node-jsx and then require your JSX files as needed.
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"]} ...
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.