When should i use npm with “-g” flag and why?

前端 未结 2 1931
长发绾君心
长发绾君心 2020-12-04 08:35

I\'ve started using npm for js package management recently. Although I do have a fair understanding of package management in different enivronments(lets say using apt, rvm/g

相关标签:
2条回答
  • 2020-12-04 09:14

    While the accepted answer is correct, be aware that there is also npx which allows to conveniently run local tools.

    For more information, see https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner

    0 讨论(0)
  • 2020-12-04 09:30

    -g is the global install flag, as explained in this answer. It's covered in detail in this node blog post.

    The rules of thumb:

    • Install globally if the package provides command-line tools
    • Install locally if you're using the package as part of your application
    • Install globally and locally if both use-cases apply
    0 讨论(0)
提交回复
热议问题