Is there a way to automatically build the package.json file for Node.js projects

后端 未结 10 900
梦毁少年i
梦毁少年i 2020-11-29 14:30

Is package.json supposed to be manually edited? Couldn\'t a program like npm just look through the files, see the \"require\" statements, and then use that to put the necess

10条回答
  •  失恋的感觉
    2020-11-29 15:03

    First off, run

    npm init
    

    ...will ask you a few questions (read this first) about your project/package and then generate a package.json file for you.

    Then, once you have a package.json file, use

    npm install  --save
    

    or

    npm install  --save-dev
    

    ...to install a dependency and automatically append it to your package.json's dependencies list.

    (Note: You may need to manually tweak the version ranges for your dependencies.)

提交回复
热议问题