Npm Cheat Sheet



For GPG versions 2.x only.

  1. Npm Yarn Cheat Sheet
  2. Npm Cheat Sheet Pdf
  3. Npm Cheat Sheet 2020
  4. Npm Commands Cheat Sheet

List keys

Install package.json dependencies. # install npm i. Npm commands’ cheat-sheet Communities for node programming and npm packages are increasing exponentially day by day. While using the npm packages, many times we need to check what is the latest version on the repository and installed version of a package locally, what are their dependencies, license, etc. Everytime we have to google for the.

List public keys

List all secret keys

List public or secret keys, but show subkey fingerprints as well

The key ring location is normally shown on the first line on stdout.

Use different key ring

List keys but use a different home directory for one command only

Set different home directory for session

Generate keys

Generate key pair

Exporting keys

Export single public key or secret key, useful for backing up keys

Export all keys

Exported secret keys are protected with current secret key passphrase.

Importing keys

List contents of key file without importing it

Verbose option to see fingerprint or both fingerprint/signatures too

Import keys, merging into current key ring

Signing a key

View the fingerprint of a key, after confirming the key is authentic, sign the key.

Or via the key editor

Optionally, export the key again and return to user

Signing a key will automatically set the key's trust level to full.

If you local sign a key, the exported key to others doesn't contain the signatures, the signature is only valid to you

Edit key trust

The trust level you enter is based on:

Use ultimate only for keys you've generated yourself. Signing a key will automatically set the key's trust level to full.

Generate a revocation certificate

Renew an expired (sub)key

To change the expiry of a key

Then export the new key for distribution, and generate a new revocation certificate for safekeeping. The secret key doesn't change.

Encryption

Encrypt file to one recipient key. This will write to a default filename, in this case file.txt.gpg

Sign and encrypt a file

Encrypt to multiple recipients

Encrypt and specify output file

Encryption uses compression by default. To disable, use the option -z 0. This will speed up the process if encrypting a large file which is already compressed.

Encrypt contents from standard input

Symmetrically encrypt a file using a passphrase

Create or verify signature

Npm Yarn Cheat Sheet

Sign file without encrypting, using a detached signature. This will write to a default file file.txt.asc in the example below.

But with clear signed attached signature

Sign using a non default secret key. Useful if you have multiple secret keys on your key ring.

Verify a clearsigned or dettached signature

Decryption

Npm Cheat Sheet Pdf

List recipients of a encrypted file

Decrypt a file to user defined output filename

Decrypt a file using default file name, e.g file.txt.gpg decrypts to file.txt

Batch encrypt and decrypt

Encrypt all *.jpg files in the current directory to two recipients, with no compression

Decrypt all *.gpg files in current directory. If --output is not used, it will write file.txt.gpg to file.txt

Do the same using a shell script

Decrypt using passphrase from standard input

I am not happy with the official npm documentation as I never find quickly what I am looking for. So I decided to write a short npm cheat sheet with the most often commands I use.

Get npm help

npm -h or npm -h

Npm cheat sheet pdfNpm Cheat Sheet
Generate package.json in a module directory, based on npm parameters.
Npm update cheat sheet

npm init
npm init -y (accept all default answers)

Install a package and also update package.json with the installed version and package name.

Npm Cheat Sheet 2020

npm install --save
npm install @1.8.2 --save --save-exact (specific version)

Install a package and also update package.json with the installed version and package name, but into the devDependencies section.

npm install --save-dev

Uninstall package (A nice thing about npm is you can always just rm -rf ./node_modules/)

Npm Commands Cheat Sheet

npm uninstall --save

List installed packages with dependency tree depth of zero.

npm ls --depth 0

List outdated libraries compared to currently installed node_modules.

npm outdated

Update dependencies.

npm update
npm update --prod (only prod dependencies)
npm update --dev (only dev dependencies)

List all npm configuration flags.

npm config ls -l

Setting, getting and deleting defaults.

npm set 'value'
npm get
npm config delete

Update the global npm version.

npm update npm -g (run this command with admin privileges)

⇒ Note that this is not working under windows. The best way to update npm is to install npm-windows-upgrade and do the update with this tool.

npm install -g npm-windows-upgrade
npm-windows-upgrade

npm shortcuts.