Basic Node
by John Vincent
Posted on February 18, 2017
This stuff ends up sprayed everywhere, so let's create a reference document.
Node
Install / Update
From NodeJS
- Download recommended version, this file for example
- Execute the package file
installs to
/usr/local/bin/node
/usr/local/bin/npmwhich node
which npmCheck versions
node -v
npm -vGlobal Node modules are kept in
/usr/local/lib/node_modules
Path
Ensure /usr/local/bin is in your PATH
Update Npm
One option is to update by updating Npm as outlined above.
Preferred
sudo npm install -g npm Npm Global Modules
For example
sudo npm install -g lesswill install less as /usr/local/bin/lessc
Update Global Modules
For example
sudo npm update -g lessNpm Cache
cd
cd .npm
lswill show the cached files.
Npm Clean Cache
sudo npm cache cleanNpm Error
For example
npm list -g grunt
Unmet Peer Dependency grunt@~0.4.2may require some upgrades.
Package Install
For example
npm install underscore
npm install underscore@1.7.0
sudo npm update underscore
npm uninstall underscoreSearch for a Package
sudo npm search mkdirshows packages including mkdir allowing for sudo npm install -g mkdirp
Nodemon
sudo npm install -g nodemon
nodemon server.jsUse a Package
For example mkdir.js
var mkdirp = require('mkdirp');
mkdirp('foo', function (err) {
if (err) console.error(err)
else console.log('Directory created!')
});and then
node mkdir.jscreates directory foo
DevTool - NodeJS Debugger
sudo npm install -g devtool
devtool app.js —breakLess
sudo npm install -g less
lessc styles.less styles.css
lessc styles.less ../css/styles.cssYarn
npm install -g yarn
yarn -vuglifyjs
sudo npm install uglify-js --global
uglifyjs mkdir.js -o mkdir.min.jsGrunt
sudo npm install -g grunt-cli
sudo npm install -g grunt-initgrunt --version
grunt-cli v0.1.13Other
npm config list
npm config get prefix
npm list --global
npm list -g --depth=0Grunt
Less
Mac
Node
- Add Mongoose to blogging app
- Basic Express Server
- Basic Node
- Basic React Redux App
- Basic Redis
- Deploy Node Express App to Heroku using Travis Continuous Integration
- Install Node 8.10 on MacOS
- Json Web Tokens
- Mocha Chai Notes
- Node Basic authentication and access control
- Node Environment
- Overview of Deployment of a Node API Server
- React/Redux Node/Express Ecosystem
- Sending Emails from Express Application