Difference between revisions of "My Node.js notes"
m (add package.json area) |
|||
Line 5: | Line 5: | ||
Initialize an npm project. Within project directory use <code>npm init</code> command. The default command launches a questionnaire. To answer default on all questions use -y argument. | Initialize an npm project. Within project directory use <code>npm init</code> command. The default command launches a questionnaire. To answer default on all questions use -y argument. | ||
Uninstall global module | |||
<pre>npm uninstall -g nodemon</pre> | |||
Install local module | |||
<pre>npm install nodemon</pre> | |||
== Basic stuff == | == Basic stuff == |
Revision as of 13:21, 20 July 2019
Node.js Package Manager (npm)
Initialize an npm project. Within project directory use npm init
command. The default command launches a questionnaire. To answer default on all questions use -y argument.
Uninstall global module
npm uninstall -g nodemon
Install local module
npm install nodemon
Basic stuff
debugger statement and node inspect
chrome:://inspect
Exit Chrome DevTool debugger.
Type restart
at console after exiting Chrome DevTool to restart app with same arguments.
Press CTRL+C twice to exit debugger in console.
nodemon
nodemon <app.name> -e <comma separated list of extensions to monitor>
package.json info
scripts key
create key value pair where key is name of script and value is script location
Example:
"scripts": { "dev": "nodemon src/app.js -e js,hbs" }
At node prompt type npm run dev
to execute script nodemon src/app.js -e js,hbs
nodemon src/app.js -e js,hbs
NPM modules
CORS is a node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options.
Resources
Node.js home
To software notes