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?
Related
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.
I am just getting started with node. I have installed the nodemon using the command npm install -g nodemon now whenever I start my server using nodemon server.js it starts fine but as I make some changes to the code it just keeps on restarting the server which doesn't execute the code in the file, so my progress is not saved.
Ansh#LAPTOP-7QQ43AM7 MINGW64 /f/files/atom/Web Development/my-express-server
$ nodemon server.js
[nodemon] 1.19.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Server has started on port 3000
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
Instead of starting the server again after restarting, it just stays in the restarting process
after executing >> "grunt server" i saw these errors i don't know what and where i need to attach or detach some code.
one more thing DeprecationWarning: while nowhere in the code i wrote node --debug and node --debug-brk.
$ grunt server
Running "server" task
>> The `server` task has been deprecated. Use `grunt serve` to start a server.
Running "serve" task
Running "clean:server" (clean) task
>> 0 paths cleaned.
Running "env:all" (env) task
Running "express:dev" (express) task
Starting background Express server
(node:5497) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead.
Stopping Express server
Running "wait" task
>> Waiting for server reload...
Done waiting!
jit-grunt: Plugin for the "watch" task not found.
If you have installed the plugin already, please setting the static mapping.
See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "watch" failed. Use --force to continue.
Aborted due to warnings.
Execution Time (2018-09-25 12:24:48 UTC+5:30)
loading tasks 124ms ▇▇▇▇ 7%
express:dev 106ms ▇▇▇ 6%
wait 1.5s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 85%
Total 1.8s
Solution
npm install grunt-contrib --save-dev
and add this line before the last line of grunt.js:
grunt.loadNpmTasks('grunt-contrib');
I am starting my node application using grunt command. My Gruntfile.js is:
module.exports = function(grunt) {
grunt.initConfig({
nodemon: {
dev: {
script: 'server.js'
}
},
watch: {
css: {
files: ['src/css/*.scss'],
tasks: ['sass:dev']
},
js: {
files: ['src/js/*.js'],
tasks: ['uglify:dev']
}
},
concurrent: {
options: {
logConcurrentOutput: true
},
tasks: ['nodemon','watch']
}
});
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-concurrent');
grunt.registerTask('default',['concurrent']);
};
When I run the application typing grunt I get the following output:
C:\Projects\SocialMeal>grunt
Running "concurrent:tasks" (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: *.*
[nodemon] starting `node server.js`
Then every console.log() call at server.js is not shown. If I start the app using node server.js the console.log() messages are shown.
Any hint?
Found it thanks to greuze. The problem was nodemon version. Changed it to 1.11.0 and the console.log outputs works now.
Simply removed the current version installed:
npm uninstall grunt-nodemon
And changed package.json:
"grunt-nodemon": "~1.10.0",
I do get console.log outputs.
I have an server.js file with content:
let name = 'Peter';
console.log(`My name is: ${name}`);
I used your Gruntfile.js.
I get this output after running grunt:
Running "concurrent:tasks" (concurrent) task
Running "watch" task
Waiting...
Running "nodemon:dev" (nodemon) task
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
My name is: Peter
[nodemon] clean exit - waiting for changes before restart
Note that there is the console.log output. Are you sure your process is not stuck anywhere?
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 :-)