Installation
Windows
Linux
- install Node.js using the "Node.js Version Manager" nvm details
- restart terminal (or...
export NVM_DIR="/home/m/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
- nvm ls-remote --lts
- nvm install --lts # to get the latest long-term-support release - you can pick a release too if needed, eg 5.8.0)
- nvm ls # show what you have
- nvm alias default stable # needed?
- the common .bashrc_env should take care of node setup
- additional fyi goo
- nvm use 4.2.1; node -v; nvm ls; nvm alias default 0.11.13; nvm use default
- You can create an .nvmrc file containing version number in the project root directory and it will default to that version
- Global package install example: npm install -g rad-scripts
Upgrade
Don't mess with anything other than lts, you've been warned:
Development
ExpandRegister with npm
|
A one-time registration is required on a new machine if you want to publish from it:
npm adduser
Username: moodboom
Password: (see private)
Email: (this IS public) moodboom@gmail.com
|
ExpandPublish a node module
|
sudo npm install -g # keep doing this until you are happy with local install
# update version in package.json
# this creates a FULL "annotated" tag, not a "lightweight" tag that doesn't show up for [git describe] - it also removes the need for a separate commit
git tag -a 1.0.5 -m "changes include..."
git push && git push --tags # NOTE: bitpost has a git hook to push changes all the way up to github
npm publish
|
ExpandUpdate a node module's dependencies
|
# make sure dependency in package.json has a carat at the beginning of its version (^x means "at least" version x)
# make sure the dependency has a new version available - completely publish it first if it is your own
# then you can simply reinstall from within the module folder to get all dependencies upgraded
sudo npm install -g
|
ExpandDevelop several node modules at once
|
Convert dependencies to use local packages instead of published versions, eg:
cd ~/development/mah-haus
npm install -S /home/m/development/thedigitalage/rad-scripts
Then reinstall everything (local dependent modules, then parent modules, pita - consider links if doing longer-term dev)
sudo npm install -g
Then convert back to published versions as they become available (it's up to me to stabilize and publish new module versions):
cd ~/development/mah-haus
npm install -S rad-scripts
|
Libraries
Expandauto AWS
|
- npm install -g aws-sdk
- Add credentials here: C:\Users\Administrator\.aws
- see existing scripts, anything is possible
|
Expandinstall bootstrap
|
- npm install -g grunt-cli
- mkdir mysite && cd mysite
- npm install bootstrap
- cd node_modules/bootstrap
- npm install # to actually pull down dependencies
- grunt dist # builds and minifies so you're good to go!
|
Troubleshoot
- After installing a new node version with [nvm install --lts], you'll have to reinstall all node packages. You should be able to run [mh scripts]. Here's what it does:
cdr && npm install -g; cdm && npm install -g; cdas && npm install -g
Warning: I had trouble when globally installing rad-scripts from npm and from my local source; for now I'll avoid [npm install -g rad-scripts].
I have also had problems with file locking and permissions when tools like Visual Studio Code are running.
fixes:
x close visual studio and kill all node exes (this didn't help this time but has in the past i think?)
* remove the globally-officially-installed rad-scripts as it blocks installation from the local repo
rm -rf /home/m/.nvm/versions/node/v8.12.0/lib/node_modules/rad-scripts
Apparently, we should always use npm install -g from [cdr], not [npm install -g rad-scripts]
F'in npm. cmon up your game before yarn etc fragments things into oblivion...
- If filesystem navigation is slow, loadning npm can be EXTREMELY slow; you can add [ --no-use] to startup, then call [node use] before using it, as a shitty workaround. I'll keep upgrading npm until it is sane. It sure has had a rough growing journey.