This setup will guide you on setting up Node.js via nvm, specifying a project Node.js versions with .nvmrc
, initializing your package.json
, and installing core dependencies.
Install nvm (Node Version Manager): https://github.com/nvm-sh/nvm#installing-and-updating
# Install the latest LTS of Node.js
# - Reinstall previous packages
nvm install --lts --reinstall-packages-from=node
# Set default to most current version of node and use
nvm alias default node
nvm use default
# OPTIONAL: Update global packages (if updating from old version)
# npm update -g
# Set current Node.js version in project .nvmrc
# - Alt. example with static version # `echo "v18.17.1" > .nvmrc`
node -v > .nvmrc
# Use project Node.js version
nvm use
# Initialize the package (es6 will specify type="module" and it will not prompt you for details)
npm init es6
# Set package.json properties
npm pkg set name="desired_name"
npm pkg set author="fh"
npm pkg set license="NONE"
npm pkg set main="dist/cli.js"
You may want to set these other properties by hand:
license
- https://choosealicense.com/private
-true|false
, set totrue
if not intending to share with publicengines.node
- Set minimum Node.js versionengines.npm
- Set minimum npm versiondescription
- Set an optional description for the projecthomepage
- Set a webpage for the project (good to use GitHub/GitLab project link)bugs
- Set an issues webpage for the project (good to use GitHub/GitLab project issues link)repository.url
- Set a URL for the project's git repo
- Core dependencies
dotenv
-.env
configuration support
- Dev dependencies
rimraf
- cross-platform rm support (for Windows support)
# Install dependencies from package.json
npm install
# Install manually (just here for reference)
npm install dotenv --save
npm install rimraf --save-dev