How to generate nodejs express package.json dependencies

When I started developing my first nodejs express application, I added a lot of packages with npm number.

I would like to know if there is a way to create a package.json file containing all current dependencies or a list of current packages in the nodes_modules directory.

+4
source share
2 answers

Run npm list to find out what you have installed. Run npm shrinkwrap to build the npm-shrinkwrap.json , which you can use as a source link to create the correct package.json . My workflow should always update package.json and then run npm install . I never ran npm install foo to get some kind of package, because it creates the risk of forgetting to add it to package.json , and then not launching the application upon deployment.

Updated to add . I am currently running npm install --save foo or npm install --save-dev foo , as I have now decided that the version numbers ~0.4.3 that it adds to package.json are better than my previous preference 0.4.x since ~ gives you a more accurate minimum version number.

+8
source

Just run npm init in the same directory as your project.

You will be asked a list of questions (name, version, description, etc.), and after its completion, it will create a package.json file with all the dependencies installed in the node_modules directory.

+9
source

Source: https://habr.com/ru/post/1444900/


All Articles