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?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Ignore Typescript errors in Webpack-dev-server
- google-drive can't get push notifications
- Webpack Encore: cannot import local dependencies
- How to reimport module with ES6 import
相关文章
- node连接远程oracle报错
- 运行"WEBPACK_ENV=online webpack -p",如何将.scss e6文件转化
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- React and typescript with webpack typing issue
- Transactionally writing files in Node.js
package-lock.json file relies on the presence of a package.json file, So it's not possible to retrieve package.json (happy to be proved wrong).
So a possible solution left is to use a module like auto-install which is capable of generating package.json from the project file dependencies.
First, you need to install the module globally
npm install -g auto-install
. Then runnpm init
and answer the basic requirements.Then, run
auto-install
in your project root directory. All the dependencies should reflect in package.json file.**
Or Install node modules directly from package-lock.json
**
Run
npm ci
which bypasses a package’s package.json to install modules from a package’s lockfile.More Information
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 inpackage-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 runnpm install pkg1 pkg2 pkg3 ...
then runnpm init
it will create the dependencies in package.json.