Skip to content

Instantly share code, notes, and snippets.

@AvnerCohen
Last active August 28, 2025 08:29
Show Gist options
  • Save AvnerCohen/4051934 to your computer and use it in GitHub Desktop.
Save AvnerCohen/4051934 to your computer and use it in GitHub Desktop.

Revisions

  1. AvnerCohen revised this gist Apr 13, 2023. 1 changed file with 20 additions and 20 deletions.
    40 changes: 20 additions & 20 deletions npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@ Node.js - npm Cheat Sheet
    ===
    (Full description and list of commands at - https://npmjs.org/doc/index.html)

    ##List of less common (however useful) NPM commands
    ## List of less common (however useful) NPM commands

    ######Prepand ./bin to your $PATH
    ###### Prepand ./bin to your $PATH
    Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:

    ````sh
    @@ -13,57 +13,57 @@ export PATH="$PATH:./node_modules/.bin"

    This will allow executing npm binaries installed into the .bin local and isolated current ./node_modules

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

    ```
    npm install <module-name> --save
    ```

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

    ```
    npm install <module-name> --save-dev
    ```

    ######Set --save as a default for ```npm install ```.
    ###### Set --save as a default for ```npm install ```.

    ```
    npm config set save true
    ```

    ######Generate package.json in a module directory, based on npm parmaters.
    ###### Generate package.json in a module directory, based on npm parmaters.

    ```
    npm init
    ```


    ######List all npm configuration flags.
    ###### List all npm configuration flags.

    ```
    npm config ls -l
    ```


    ######Install a version not from a git repository and not from the npm directory, for example:
    ###### Install a version not from a git repository and not from the npm directory, for example:

    ```
    npm install git://github.com/substack/node-browserify.git
    ````
    ######Update the global npm version.
    ###### Update the global npm version.
    ```
    npm update npm -g
    ```
    ######Display the readme.md / documentation / npmjs.orf page of a give library.
    ###### Display the readme.md / documentation / npmjs.orf page of a give library.
    ```
    npm docs <module-name>
    ```
    ######Run package test suite, based on setup in package.json in:
    ###### Run package test suite, based on setup in package.json in:
    ``` "scripts" : {"test" : "node testfile.js"} ```
    @@ -72,55 +72,55 @@ npm docs <module-name>
    npm test
    ```
    ######Uninstall package (A nice thing about npm is you can always just ```rm -rf ./node_modules/<module_name>```).
    ###### Uninstall package (A nice thing about npm is you can always just ```rm -rf ./node_modules/<module_name>```).
    ```
    npm uninstall <module_name>
    ```
    ######Locally edit a dependency.
    ###### Locally edit a dependency.
    ```
    npm edit <module_name>
    ```
    ######Setup editor for ```npm edit ``` :
    ###### Setup editor for ```npm edit ``` :
    ```
    npm config set editor "sublime"
    ```
    ######Publish a package not under the default "latest" tag:
    ###### Publish a package not under the default "latest" tag:
    ```
    npm publish --tag beta
    ```
    ######Test & Show the full dependency tree
    ###### Test & Show the full dependency tree
    ```
    npm install --dry-run
    ```
    ######List outdated libraries compared to currently installe node_modules:
    ###### List outdated libraries compared to currently installe node_modules:
    ```
    npm outdated
    ```
    ######Lock down dependency versions:
    ###### Lock down dependency versions:
    ```
    npm shrinkwrap
    ```
    ######Install a git specific release
    ###### Install a git specific release
    ```
    npm install git://github.com/Marak/colors.js#v0.6.0
    ```
    ######Easter Eggs
    ###### Easter Eggs
    ```
    npm xmas
  2. AvnerCohen revised this gist Jun 9, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -96,10 +96,10 @@ npm config set editor "sublime"
    npm publish --tag beta
    ```
    ######Show the full dependency tree
    ######Test & Show the full dependency tree
    ```
    npm ls
    npm install --dry-run
    ```
    ######List outdated libraries compared to currently installe node_modules:
  3. AvnerCohen revised this gist Jun 9, 2016. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -96,6 +96,12 @@ npm config set editor "sublime"
    npm publish --tag beta
    ```
    ######Show the full dependency tree
    ```
    npm ls
    ```
    ######List outdated libraries compared to currently installe node_modules:
    ```
  4. AvnerCohen revised this gist Nov 20, 2014. 1 changed file with 18 additions and 1 deletion.
    19 changes: 18 additions & 1 deletion npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -112,4 +112,21 @@ npm shrinkwrap
    ```
    npm install git://github.com/Marak/colors.js#v0.6.0
    ```
    ```
    ######Easter Eggs
    ```
    npm xmas
    ```
    ```
    npm visnup
    ```
    ```
    npm substack
    ```
  5. AvnerCohen revised this gist Dec 12, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -108,7 +108,7 @@ npm outdated
    npm shrinkwrap
    ```
    #####Install a git specific release
    ######Install a git specific release
    ```
    npm install git://github.com/Marak/colors.js#v0.6.0
  6. AvnerCohen revised this gist Dec 12, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Node.js - npm Cheat Sheet

    ##List of less common (however useful) NPM commands

    ##### Prepand ./bin to your $PATH
    ######Prepand ./bin to your $PATH
    Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:

    ````sh
  7. AvnerCohen revised this gist Dec 12, 2013. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,14 @@ Node.js - npm Cheat Sheet

    ##List of less common (however useful) NPM commands

    ##### Prepand ./bin to your $PATH
    Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:

    ````sh
    export PATH="$PATH:./node_modules/.bin"
    ````

    This will allow executing npm binaries installed into the .bin local and isolated current ./node_modules

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

  8. AvnerCohen revised this gist Dec 9, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Node.js npm Cheat Sheet
    Node.js - npm Cheat Sheet
    ===
    (Full description and list of commands at - https://npmjs.org/doc/index.html)

  9. AvnerCohen revised this gist Dec 9, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Node.js's npm Cheat Sheet
    Node.js npm Cheat Sheet
    ===
    (Full description and list of commands at - https://npmjs.org/doc/index.html)

  10. AvnerCohen revised this gist Dec 9, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    NPM Cheat Sheet
    Node.js's npm Cheat Sheet
    ===
    (Full description and list of commands at - https://npmjs.org/doc/index.html)

  11. AvnerCohen revised this gist Dec 7, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -98,4 +98,10 @@ npm outdated
    ```
    npm shrinkwrap
    ```
    #####Install a git specific release
    ```
    npm install git://github.com/Marak/colors.js#v0.6.0
    ```
  12. AvnerCohen revised this gist Nov 25, 2012. 1 changed file with 14 additions and 2 deletions.
    16 changes: 14 additions & 2 deletions npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    NPM Cheat Sheet
    ===
    (Full description and list of commands at - https://npmjs.org/doc/index.html)

    ##List of less common NPM commands

    ##List of less common (however useful) NPM commands


    ######Install a package and also update package.json with the installed version and package name.
    @@ -87,3 +87,15 @@ npm config set editor "sublime"
    ```
    npm publish --tag beta
    ```
    ######List outdated libraries compared to currently installe node_modules:
    ```
    npm outdated
    ```
    ######Lock down dependency versions:
    ```
    npm shrinkwrap
    ```
  13. AvnerCohen revised this gist Nov 12, 2012. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -80,4 +80,10 @@ npm edit <module_name>
    ```
    npm config set editor "sublime"
    ```
    ```
    ######Publish a package not under the default "latest" tag:
    ```
    npm publish --tag beta
    ```
  14. AvnerCohen revised this gist Nov 10, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,7 @@ npm config ls -l
    ######Install a version not from a git repository and not from the npm directory, for example:

    ```
    npm install git@github.com:substack/node-browserify.git
    npm install git://github.com/substack/node-browserify.git
    ````
    ######Update the global npm version.
    @@ -80,4 +80,4 @@ npm edit <module_name>
    ```
    npm config set editor "sublime"
    ```
    ```
  15. AvnerCohen created this gist Nov 10, 2012.
    83 changes: 83 additions & 0 deletions npm-cheat-sheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,83 @@
    NPM Cheat Sheet
    ===

    ##List of less common NPM commands



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

    ```
    npm install <module-name> --save
    ```

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

    ```
    npm install <module-name> --save-dev
    ```

    ######Set --save as a default for ```npm install ```.

    ```
    npm config set save true
    ```

    ######Generate package.json in a module directory, based on npm parmaters.

    ```
    npm init
    ```


    ######List all npm configuration flags.

    ```
    npm config ls -l
    ```


    ######Install a version not from a git repository and not from the npm directory, for example:

    ```
    npm install [email protected]:substack/node-browserify.git
    ````
    ######Update the global npm version.
    ```
    npm update npm -g
    ```
    ######Display the readme.md / documentation / npmjs.orf page of a give library.
    ```
    npm docs <module-name>
    ```
    ######Run package test suite, based on setup in package.json in:
    ``` "scripts" : {"test" : "node testfile.js"} ```
    ```
    npm test
    ```
    ######Uninstall package (A nice thing about npm is you can always just ```rm -rf ./node_modules/<module_name>```).
    ```
    npm uninstall <module_name>
    ```
    ######Locally edit a dependency.
    ```
    npm edit <module_name>
    ```
    ######Setup editor for ```npm edit ``` :
    ```
    npm config set editor "sublime"
    ```