Running node.js w/ supervisor in win8 - node.js

I'm trying to get my node server running w/ supervisor. I had it working in Windows 7, but now it keeps failing. Here's the output:
"C:\Program Files\nodejs\node.exe" C:\Users\Mark\AppData\Roaming\npm\node_modules\supervisor\lib\cli-wrapper.js --no-restart-on error server.js
DEBUG: Running node-supervisor with
CreateProcessW: The system cannot find the file specified.
DEBUG: program 'server.js'
DEBUG: --watch '.'
DEBUG: --ignore 'undefined'
DEBUG: --extensions 'node|js'
DEBUG: --exec 'node'
DEBUG: Starting child process with 'node server.js'
DEBUG: Watching directory 'D:\Websites\MyProject' for changes.
DEBUG: Program node server.js exited with code 127
This guy suggested trying nodemon instead, but the result is more or less the same:
"C:\Program Files\nodejs\node.exe" C:\Users\Mark\AppData\Roaming\npm\node_modules\nodemon\nodemon.js server.js
26 Jan 22:23:10 - [nodemon] v0.7.1
26 Jan 22:23:10 - [nodemon] watching: D:\Websites\MyProject
26 Jan 22:23:10 - CreateProcessW: The system cannot find the file specified.
[nodemon] starting `node server.js`
26 Jan 22:23:10 - [nodemon] app crashed - waiting for file changes before starting...
However, if I run "vanilla" node.js, it starts up fine:
"C:\Program Files\nodejs\node.exe" server.js
Listening on http://localhost:8081
What might be the problem? Is it the server.js file it can't find? Why wouldn't it be able to find it?

Rebooted Windows, problem went away. It starts up fine now. Probably just needed to restart either Windows or my IDE to refresh some file paths :-)

Related

Unable to launch nodemon environment

I'm trying to start my server with nodemon, but it crashes with the following output.
The error ERROR: Unrecognized environment. Aborting. seems quite rare, from a Google search.
Ran the same code in Windows 10 and a WSL2 Ubuntu set up. Both had the same results. The server does start for my coworker for some reason, though.
user#LAPTOP:~/myproject$ npm run start:dev
> myproject#0.0.0 start:dev /home/user/myproject
> nodemon
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts,html
[nodemon] starting `./node_modules/.bin/ts-node -r tsconfig-paths/register ./src`
[2021-03-23T04:11:42.704Z] ERROR: Unrecognized environment. Aborting.
[nodemon] app crashed - waiting for file changes before starting...
^C
user#LAPTOP:~/myproject$ npm -v
6.14.11
user#LAPTOP:~/myproject$ node -v
v15.12.0
This is a bug with my sequelize code
The issue came from trying to access the sequelize.js database before connecting to it.
Moving my Model.findAll() statement to after the app has launched has fixed the issue.

MEAN app - no logs

I have an application running on a node server. The application is running fine, but unfortunately I do not see any logs in the terminal window. When I do npm start, I get the following output in the terminal:
> app#0.1.0 start /Users/prerak/WebProjects/app/www
> grunt
Running "jshint:all" (jshint) task
Running "csslint:all" (csslint) task
Warning: Unable to read ".csslintrc" file (Error code: ENOENT). Used --force, continuing.
Running "concurrent:default" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/views/**/*.* gruntfile.js server.js config/**/*.js app/**/*.js
[nodemon] starting `node --debug server.js`
I have some calls to console.log in my server.js file but I do not see them in the terminal. Is there anything else that I can do to get the logs?
For the application without any errors it's fine but if there are any issues, it's very difficult to debug the issue. In case of an error, I get the following in the logs:
> app#0.1.0 start /Users/prerak/WebProjects/app/www
> grunt
Running "jshint:all" (jshint) task
Running "csslint:all" (csslint) task
Warning: Unable to read ".csslintrc" file (Error code: ENOENT). Used --force, continuing.
Running "concurrent:default" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/views/**/*.* gruntfile.js server.js config/**/*.js app/**/*.js
[nodemon] starting `node --debug server.js
[nodemon] app crashed - waiting for file changes before starting...
I do not get any stackstace of the issue.
I have also configured my express server to show the stacktrace as:
var app = express();
app.set('showStackError', true);
I have this issue on Mac OSX 10.12 but if I run the same code on Ubuntu 14.10, it shows the logs in the terminal.
Also, instead of npm start if I do node server.js it shows the logs. What can be the reason behind this?

What is the issue "node" is working but "nodemon" is not woking on windows 7 64-bit in node.js?

I am new to node.js. node is working fine but when I installed the nodemon package, it gives an error: exception in nodemon killing node, even when installed globally.
22 Jun 13:07:29 - [nodemon] v1.3.7
22 Jun 13:07:29 - [nodemon] to restart at any time, enter `rs`
22 Jun 13:07:29 - [nodemon] watching: *.*
22 Jun 13:07:29 - [nodemon] starting `node server.js`
exception in nodemon killing node
Error: spawn cmd ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
----------------------------------------------------------
If appropriate, please file an error with the output from:
$ node
C:\Users\username\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.
js server.js --dump
At http://github.com/remy/nodemon/issues/new
Possible solutions.
1. Permissions
The problem may be in your file permissions. Execute in git bash or from windows to give full permission to the project folder.
$ chmod -R 777 [folder]
2. Environment Variables
Missing "C:\Windows\System32" in the PATH.
Github issue
3. Reinstall
Altogether remove nodemon using npm and try reinstalling.
npm uninstall -g nodemon
4. Update nodejs
If you have an old version of NodeJS, try updating it. I prefer entirely removing NodeJS and reinstalling it again.
Step by steps to remove NodeJS in windows
Note: Your question may not be rich enough to answer correctly. Please include more information about questions if those didn't work.
Help spawn to locate your nodemon.cmd like this:
var nodemonCmd = (process.platform == 'win32') ? 'node_modules\\.bin\\nodemon.cmd' : 'nodemon'
myApp = spawn(nodemonCmd, ['build/server.bundle']);
Hope it works :)

Emfile error running nodemon

Can't seem to get nodemon up and running.
It works when using just node (node app.js) but when using nodemon (nodemon app.js) the following Emfile error is returned:
20 Nov 12:26:33 - [nodemon] v0.7.10
20 Nov 12:26:33 - [nodemon] to restart at any time, enter `rs`
20 Nov 12:26:33 - [nodemon] watching: /home/ramzi/ST/swaggertrack
20 Nov 12:26:33 - [nodemon] starting `node app.js`
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Express server listening on port 80
mongo is connected
EMFILE: Watching too many files.
EMFILE: Watching too many files.
EMFILE: Watching too many files.
EMFILE: Watching too many files.
Has anyone got any thoughts?
Thanks.
If you update to nodemon#1.0.12 (currently latest) it will warn out if there's too many files being watched (i.e. > 25,000 files - a rough arbitrary number I chose). If you don't get that warning, it's possible it's your script.
Happy to help debug (assuming you're on the latest version) at http://github.com/remy/nodemon/issues/new

Nodeclipse + Nodemon dont want to start apps

i set in prefences in Node Path C:!NnS\NodeJS!LIBS\nodemon.cmd
nodemod.cmd
"%~dp0\node.exe" "%~dp0\node_modules\nodemon\nodemon.js" %*
error
21 Aug 17:12:11 - [33m[nodemon] v0.7.10[0m
21 Aug 17:12:11 - [33m[nodemon] to restart at any time, enter rs[0m
21 Aug 17:12:11 - [32m[nodemon] watching: C:\Users\Admin\Desktop\nodeclipse-NTS-jee-kepler-win64\ws\NodeProject-1[0m
Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)
21 Aug 17:12:11 - [32m[nodemon] starting node C:\Users\Admin\Desktop\nodeclipse-NTS-jee-kepler-win64\ws\NodeProject-1\hello-world-server.js[0m
21 Aug 17:12:11 - [nodemon] exception in nodemon killing node
if i will start "nodemod.cmd app.js" all works
ps.
nodemon plugins for whatch on filechanges and make restart on any changes
https://github.com/remy/nodemon
Running node application with node-dev, forever, supervisor, nodemon etc
as of Nodeclipse 0.4.0 is not yet supported, issue #57 https://github.com/Nodeclipse/nodeclipse-1/issues/57
It is really smart to try enter path to such utils into Node path Preferences settings,
but it is not how that setting is meant to be used.
UPDATE (The solution you have mentioned) run app with a wrapper:
Looks like if in main app will be something like this... all will be ok :)
spawn("nodemon.cmd", ["main.js"]...
and
spawn("nodemon",[" --debug ./server.js 80"]...
But I personally would prefer to open console with StartExplorer see Plugins List
(right-click project -> StartExplorer -> open shell)
then nodemon main

Resources