2018-09-18 Mosh nodejs lecture 2

  1. in newer version of npm ,

npm i mongodb

would automatically save dependency info of mongodb into package.json of current nodejs project
only in the older version ,

npm i mongodb -S

is needed

  1. since package.json is automatically update once you run

npm i mongodb

there is no need to change package.json manually.
when you publish your code to git, just

touch .gitignore

and add node_modules/ to it, which would ignore the fodler

node_modules/

when pushing to git.

on the server, just pull the code and run

npm i,

this would install modules requeired base on the package.json file

  1. npm list
    would show all the dependencies in current project, including a tree dependceis

if you do not want such details, run

npm list --depth=0

this only list the modules required by your project , and would not show other modules depended by the former modules.

  1. the dependcies in package.json of any module could be shown by :

npm view mongodb dependencies

this would list the dependencies,while

npm view mongodb

would show all details from package.json of mongodb module

  1. npm outdated

this shows the outdated modules depended by your current project, see SemVersion and Tilda Version

npm outdated -g

shows outdated modules globally

  1. to see the real installed module version, check the packge.json in the project, or the one in the node_modules/PackageName folder

or run

npm list --depth=0

你可能感兴趣的:(2018-09-18 Mosh nodejs lecture 2)