I managed to setup nodeclipse with nodemon and I can now start my server.js script with monitor (nodemon) but something strance occurs:
On file change (even on the server.js) nodemon wont restart
In nodeclipse console I dont see the normal nodemon output, ex:
1 Aug 15:20:05 - [nodemon] v1.2.1
1 Aug 15:20:05 - [nodemon] to restart at any time, enter `rs`
1 Aug 15:20:05 - [nodemon] watching: *.*
1 Aug 15:20:05 - [nodemon] starting `node server.js`
PS: I' ve setup monitor path to nodemon.js which is installed with -g parameter
also I can not create any type of run configuration for "Node with monitor"
Is there any way to autorestart the server in nodeclipse even without nodemon if there isn't any other option...
After some time I ended up creating a Node application run configuration and simply added in the arguments tab -> Node arguments the path of nodemon.js
In my case : C:\Users\syd\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js
Now I'm able to get console feed as well stop the node server from eclipse and auto restart on file changes :)
Related
I have an application in Electron and React, in the application there is an entry where I put an ID that makes a request to a service that runs on port 6000 (which is a non-secure port)
PD: I did not do the service
[nodemon] 2.0.19
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node src/index.js`
Server on port 6000
When I run the app with electron and try to make the request with the ID, I get the following error:
Failed to load resource: net::ERR_UNSAFE_PORT localhost:6000/...
I have, so to speak, a version of the app that runs with electron and the other normal in the browser where it also gave me the same error but I solved it with the following:
https://i.stack.imgur.com/UKVrb.png
Adding that to the Google Chrome properties prevented that error, but I don't know how to do it with electronJs or if there is any way to mimic it.
I don't know why the image appears only with the link and it is not shown, in Spanish StackOverflow it was shown.
So, basically I am setting up my local server using node.js and nodemon. It starts well on localhost but when I refresh the page or open another page, the server crashes giving me this unhandled 'error' event. I have searched through some solutions and tried reinstalling the dependencies after removing the cache by using npm cache clean --force. There is an image attached showing the error.
When I start my server using nodemon
After refreshing the landing page or going to other page
In case these images doesn't show up this is my whole return from vs code from starting the server to when I refresh the page or navigate to another page:
> nodemon app.js
[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node app.js`
server listening on port: 5000
events.js:377
throw er; // Unhandled 'error' event
^
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at writeAfterEnd (_http_outgoing.js:694:15)
at ServerResponse.end (_http_outgoing.js:815:7)
at Server.<anonymous> (C:\Users\SUJAL\OneDrive\Desktop\VS code\web development\NodeJs\nodejs\app.js:17:7)
at Server.emit (events.js:400:28)
at parserOnIncoming (_http_server.js:897:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
Emitted 'error' event on ServerResponse instance at:
at writeAfterEndNT (_http_outgoing.js:753:7)
at processTicksAndRejections (internal/process/task_queues.js:83:21) {
code: 'ERR_STREAM_WRITE_AFTER_END'
}
[nodemon] app crashed - waiting for file changes before starting...
If you can even help with a temporarily solution, it will be great.
Make sure the port you're using is not in use by other services. Or, use a different port.
I had the same issue. Later realized port 5000 was being used by another service on my pc. Switched it to a different one and worked fine.
I have been working on a node.js / react app and I uploaded it to heroku. About a month ago it worked (locally and on heroku). Now it doesn't. I seem to get the same error when I run nodemon server even when I download old commits of the app (which did work). Terminal does this:
TDI-MacBook-Air:udemy-MERN-FromGithub bob$ nodemon server
[nodemon] 1.19.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Server started on Port 5000
bad auth Authentication failed.
[nodemon] app crashed - waiting for file changes before starting...
1. downloaded old an old commit from my githum https://github.com/PaulAyling/COURSE-MernStackFrontToBack
2. ran at the terminal: npm install
3. Ran at terminal nodemon server (got the same error as before).
4. I tried connecting to the mongo database with postman and got the following error:
Could not get any response
There was an error connecting to http://localhost:5000/api/posts.
Why this might have happened:
The server couldn't send a response:
Ensure that the backend is working properly
Self-signed SSL certificates are being blocked:
Fix this by turning off 'SSL certificate verification' in Settings > General
Proxy configured incorrectly
Ensure that proxy is configured correctly in Settings > Proxy
Request timeout:
Change request timeout in Settings > General
After reading the error I changed the SSL Certificate verification to off but it did not fix the problem
Theres quite alot of code - not sure what the most usefull files would be - but it did work a month ago.
The full code is here: https://github.com/PaulAyling/COURSE-MernStackFrontToBack
If you want specific code let me know and I'll post it.
Expecting the server to run. Error is;
TDI-MacBook-Air:udemy-MERN-FromGithub bob$ nodemon server
[nodemon] 1.19.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Server started on Port 5000
bad auth Authentication failed.
[nodemon] app crashed - waiting for file changes before starting...
In your /config/default.json or /config/production.json there is an object mongoURI.
Replace the url with with user password and username not your account name and account password that currently functions.
You have probably deleted that user or changed the password.
Also I tried launching in my local machine and it worked without any trouble.
If your username has special characters then change the username with URL encoded format. you will find URL encoding here!
I will recommend changing the password to eliminate special chars.
As per the Mongo DB website:
Special Characters in Connection String Password
If your password includes special characters, and you are using your password in a connection string URI, encode the special characters.
NOTE
The following characters must be converted using percent-encoding if included in a username or password:
: / ? # [ ] #
For example, if your password in plain text is p#ssw0rd'9'!, you need to encode your password as:
p%40ssw0rd%279%27%21
The above solution worked for me.
I have been trying to install the MEAN stack using the following tutorial:
http://www.bossable.com/303/install-mean-stack/#comment-1526
I am using webstorm and MongoDB.
However I have been unsuccessful and I keep getting errors. Everytime I connect to localhost:3000 I get the following error:
C:\meanproject>grunt
Running "jshint:all" (jshint) task
>> 55 files lint free.
Running "csslint:all" (csslint) task
>> 2 files lint free.
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`
Debugger listening on port 5858
Application loaded using the "development" environment configuration
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
MEAN.JS application started on port 3000
C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection
\base.js:246
throw message;
^
Error: Error setting TTL index on collection : sessions
at C:\meanproject\node_modules\connect-mongo\lib\connect-mongo.js:169:23
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.
js:1499:46
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.
js:1632:20
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\cur
sor.js:170:22
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\cur
sor.js:714:39
at Cursor.close (C:\meanproject\node_modules\mongoose\node_modules\mongodb\l
ib\mongodb\cursor.js:1009:5)
at commandHandler (C:\meanproject\node_modules\mongoose\node_modules\mongodb
\lib\mongodb\cursor.js:714:21)
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.
js:1905:9
at Server.Base._callHandler (C:\meanproject\node_modules\mongoose\node_modul
es\mongodb\lib\mongodb\connection\base.js:453:41)
at C:\meanproject\node_modules\mongoose\node_modules\mongodb\lib\mongodb\con
nection\server.js:488:18
at MongoReply.parseBody (C:\meanproject\node_modules\mongoose\node_modules\m
ongodb\lib\mongodb\responses\mongo_reply.js:68:5)
at null.<anonymous> (C:\meanproject\node_modules\mongoose\node_modules\mongo
db\lib\mongodb\connection\server.js:446:20)
at emit (events.js:107:17)
at null.<anonymous> (C:\meanproject\node_modules\mongoose\node_modules\mongo
db\lib\mongodb\connection\connection_pool.js:207:13)
at emit (events.js:110:17)
at Socket.<anonymous> (C:\meanproject\node_modules\mongoose\node_modules\mon
godb\lib\mongodb\connection\connection.js:440:22)
[nodemon] app crashed - waiting for file changes before starting...
How would I go about solving this?
You need to run the mongodb.exe file first. After successfully starting mongodb, you need to navigate into your project folder and run 'grunt'. If it shows you a error list of modules not found, you need to install those modules globally with npm. That will solve the problem for you. However, please note that bossable.com tutorial is for 0.3 mean stack boiler plate. They have upgraded their version to 0.4.1 now. Follow the Meanjs documentation
for latest information.
I follower every instruction for installing a MEAN stack application.
At the end of it all I run grunt and when I go to http://localhost:3000 I get the following error:
Running "clean:0" (clean) task
Running "jshint:all" (jshint) task
>> 47 files lint free.
Running "csslint:src" (csslint) task
>> 5 files lint free.
Running "concurrent:tasks" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...
[nodemon] v1.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
Mongoose: packages.findOne({ name: 'config' }) { fields: undefined }
3000
Mean app started on port 3000 (development)
Mongoose: users.ensureIndex({ email: 1 }) { safe: undefined, background: true, unique: true }
Mongoose: users.ensureIndex({ username: 1 }) { safe: undefined, background: true, unique: true }
GET / 304 41.185 ms - -
events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open '/var/www/finnviz/bower_components/bootstrap/dist/css/bootstrap.css'
[nodemon] app crashed - waiting for file changes before starting...
I searched and found this answer, but this does not seem to be the case, when I run ps aux | grep node I dont get any running process:
trufa 14763 0.0 0.0 23492 956 pts/14 S+ 15:39 0:00 grep --color=auto node
I searched through many answers but none seem to apply. Some suggest to change the port. I tried it and the error is the same.
Any suggestions as to how to proceed?
Sometimes the automatic bower install does not work if you run npm with sudo.
I would recommend setting up npm so it does not require sudo.
Try running $ bower install from your project root, and then restart the server.
you had run another server using the same port 8080.