- 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
- 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
-
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.
- 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
npm outdated
this shows the outdated modules depended by your current project, see SemVersion and Tilda Version
npm outdated -g
shows outdated modules globally
- 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