2018-09-18 Mosh nodejs lecture 2

1550 ワード

  • in newer version of npm,
  • npm i mongodbwould automically save dependency info of mongodb into package.json of current nodejs project only in the older version、npm i mongodb -Sis need
  • since package.json is atomaticaly udate once you run
  • npm i mongodbthere isのneed to change package.json manaualy.when you publish your code to git,justtouch .gitignoreand add node_modules/to it,which would ignore the fodler
    node_modules/
    when pusing to git.
    on the server,just pull the code and runnpm 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 dot want such details,runnpm list --depth=0this 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 dependenciesthis would list the dependencies,whilenpm view mongodbwould show all detail from package.json of mongodb module
  • npm outdated
  • this shows the out dated modules depended by your current project、see Sem Version and Tilda Versionnpm outdated -gshows outdated modules globally
  • to see the real installed module version、check the packge.json in the project、or the one in the node_modules/Package Name folder
  • or runnpm list --depth=0