Is there a way to force npm to generate package-lock.json?

后端 未结 7 617
Happy的楠姐
Happy的楠姐 2021-01-30 05:59

I deleted it by accident and have made many changes to package.json since. An npm install or npm update do not generate package-lock

相关标签:
7条回答
  • 2021-01-30 06:22

    package-lock.json is re-generated whenever you run npm i.

    0 讨论(0)
  • 2021-01-30 06:24

    When working with local packages, the only way I found to reliably regenerate the package-lock.json file is to delete it, as well as in the linked modules and all corresponding node_modules folders and let it be regenerated with npm i

    0 讨论(0)
  • 2021-01-30 06:27

    By default, package-lock.json is updated whenever you run npm install. However, this can be disabled globally by setting package-lock=false in ~/.npmrc.

    When the global package-lock=false setting is active, you can still force a project’s package-lock.json file to be updated by running:

    npm install --package-lock
    

    This command is the only surefire way of forcing a package-lock.json update.

    0 讨论(0)
  • 2021-01-30 06:30

    If your npm version is lower than version 5 then install the higher version for getting the automatic generation of package-lock.json.

    Example: Upgrade your current npm to version 6.14.0

    npm i -g npm@6.14.0
    

    You could view the latest npm version list by

    npm view npm versions
    
    0 讨论(0)
  • 2021-01-30 06:40

    In npm 6.x you can use

    npm i --package-lock-only
    

    According to https://docs.npmjs.com/cli/install.html

    The --package-lock-only argument will only update the package-lock.json, instead of checking node_modules and downloading dependencies.

    0 讨论(0)
  • 2021-01-30 06:40

    This is answered in the comments; package-lock.json is a feature in npm v5 and higher. npm shrinkwrap is how you create a lockfile in all versions of npm.

    0 讨论(0)
提交回复
热议问题