Is it ok to have a node.js project with no package.json? The ones I see on the internet all come with package.json
What is the effect of having no package.json?
It is created automatically if you write npm init
.
Then, every package you add using npm install packagename --save
will be added to the dependencies list.
You need package.json
so that when you want to use your project on another machine you don't have to copy all node_modules
, but only your .js
files you have written, assets and package.json
. You can then run npm install
command and it will automatically download and install all the required modules (found in the list of dependencies inside package.json
).
You can also manually create or edit it, but it's easier to add --save
when installing a module so you don't have to worry about package versions and stuff like that.
Also if you want to create a npm package, an open source project or stuff other people will use, it's either required or the norm to have this package.json
file describing your project.