sailsjs live update during serverside editing - node.js

It's annoying to have to restart the sails server when you change something, is there any way to make sailsjs do what meteor does where when you save a serverside file it automatically updates the clientside?
That's a pretty awesome feature, and I love sails but that feature is pretty cool.

Nodemon is a helpful development tool that watches the files in the directory that it was started in, and if anything changes are detected, your node.js application will automatically restart.
To install nodemon (you may need to use sudo)
$ npm install -g nodemon
Sails.js continually writes to the .tmp folder, and as a result you will find that nodemon will continually restart the server. To resolve this issue, simply ignore this folder by creating a .nodemonignore file with this single line, noting you can place any other files/folders you wish to ignore on separate lines
.tmp/*
To run your Sails.js application through nodemon
$ nodemon app
For more information, be sure to check out nodemon on npmjs.org

If you monitor nodemon --ignore 'tmp/*' --ext js,ejs . you will still get the infinite reload problem. Apparently Sails is constantly writing the ejs files.

Related

NodeJS close server and start again

I am brand new to React and NodeJS. I have NodeJS latest version installed on my mac as well as React. I can start and run the app using npm start I am following tutorials and it was fine and I could see my app in the browser. The problem begins when I need to finish for the day and start again the next day and I do not know how to start the server again and app and to continue the work. npm start does not work. Unfortunately tutorials only show how to start the app for the very first time, but they don't show what do you need to do to interrupt your work, shut down computer and continue the following day. What steps do I need to take in to continue my work the following day?
regarding your question the things you want to make sure that whatever project you are working on (nodejs or react) that you cd into the project folder before you run any commands as these scripts you are running "npm run start" etc.. are based on what scripts are written inside the package.json.
so if you use create-react-app for reactjs the "npm run start" is a default script that comes with CRA and will run the app for you.
for express you can also check the scripts and there will be something similar but you can do "node server.js" (or app.js depends on how you called the file you initialize the server) and it will run the server.
in summary:
make sure to cd into the correct directory
check package.json for scripts if you are not sure what they are
also run "npm install" as you might have some missing dependencies
enjoy.
If you have any more questions will edit my response to answer those as well, have a nice day ;)
Just look for error messages in the Terminal when you run npm start. Try to understand them and fix them.
You can also install Nodemon (npm i nodemon) and run nodemon {filename}.js to start the server. {filename} is the name of the file in which you're starting the server.

Nodemon and babel-node restart multiple times

I'm using nodemon with babel-node in development environment.
I'm working on Windows 7 and every time I change my code, nodemon restart multiple times.
I searched on google and even in stackoverflow and github, the temporary solution is just: re-install nodemon: npm i -g nodemon. But after some minutes, the problem come back :(
I tried add --delay sometime and even re-install node.js but it does not work
How can I fix that? This problem slow down my work :(
if you mean restart by this
then here is your answer
we use nodemon for this work
nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected. nodemon does not require any additional changes to your code or method of development.
have a look at nodemon docs
if not then
look at this answer

Nodemon + Express 4.13.4

I am losing my mind trying to get Nodemon running correctly with Express 4 ;) I have installed the npm and changed my package.json to
"scripts": {
"start": "nodemon ./bin/www"
},
I launch the server using...
npm start
If I then make any edits to a routes.js file no changes take. Even when I refresh the browser. After running ps aux | grep node I get the following..
It seems that BOTH the Nodemon AND node server are running. Has anyone else seen this and understand why? or how to fix it?
Thanks.
*UPDATE This is my console output while the server is running.
Nodemon only watches the files in the current working directory (in your case ./bin because you're running ./bin/www). Your app files aren't in that directory, so nodemon isn't watching them.
You can, however, tell nodemon to instead watch one or more other directories. In your case you just need to tell it to watch the project root, i.e. nodemon ./bin/www --watch ..
Your jade files are loaded anew on every request by express's view engine, which is why you were seeing changes made in them without you or nodemon restarting the app.
I've made a pull request on your repo which makes npm start use nodemon in this fashion.

how to do nodejs hot deployment in nodeclipse , enide studio, express server?

I am debugging an application in nodeclispe/ enide studio. I wish to change js files on the go while the express server is running, instead of doing a server restart. HOw can I do that?
Since you are debugging an application the best you can do is use the module nodemon, this module watches your folder for files change when a file changes the application is automatically redeployed.
To install nodemon use this command, install it globally:
npm install nodemon -g
To execute from CLI you use
nodemon --debug app.js
PS: Have in mind that when i say redeployed the memory of the process is flushed and do not use nodemon under production environment.

How do I monitor symlinked modules with Nodemon?

I’m developing a module in Node.js which I’ve npm-linked into another projects node_modules folder. I’d like to restart this other projects server upon file changes in my module. Nodemon ignores node_modules by default, but I assumed I could override this using nodemon --watch node_modules/my_module – but can’t get it to work. If I temporarily remove node_modules from Nodemons lib/config/defaults.js it works, which probably confirms that the problem has to do with overriding default behavior.
Using nodemon 1.2.1, I'm able to do the following to get watches working with an npm link:
$ nodemon --watch . --watch $(realpath node_modules/my_module)
Basically...you have to watch the directory you're in (your project directory), and then specify a watch to the symlink itself. nodemon by default ignores node_modules, so explicitly specifying the watch fixes this. You may try updating your version of nodemon if this doesn't work for you.

Resources