I downloaded a theme and it has a package-lock.json file but no package.json file. Is there a way I can generate the package.json from the package-lock.json file. How do I install the node modules with just the package-lock.json file. Is there a way to do that?
Description. package-lock. json is automatically generated for any operations where npm modifies either the node_modules tree, or package. json .
The package-lock. json file needs to be committed to your Git repository, so it can be fetched by other people, if the project is public or you have collaborators, or if you use Git as a source for deployments. The dependencies versions will be updated in the package-lock. json file when you run npm update .
Install the latest npm with npm install -g npm
Run npm init
and respond to the questions.
The above command will generate a package.json
and include the existing packages listed in package-lock.json
I think I figured it out.
I don't think npm init
can draw from package-lock.json. However it does seem to pull from what is already in your /node_modules. I believe this is why @Harry B's solution works for some and not at all for others.
For example, if you have just cloned your project which contains package-lock.json, no package.json, and empty/non-existence node_modules, npm init
won't create any dependencies. However, if you run npm install pkg1 pkg2 pkg3 ...
then run npm init
it will create the dependencies in package.json.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With