Yuchen
Yuchen

Reputation: 33036

Running npm install does not produce lock file

When running npm install, when will it produce a package-lock.json file and when will it not?

This is the version of npm that I am using:

$ npm --version
3.10.10

And this a simple package.josn that I am testing with:

$ cat package.json 
{
  "name": "invoices_svc",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.2"
  },
  "repository": {
    "type": "git",
    "url": "git@.../TotalInvoiceDemoApp.git"
  },
  "description": "..."
}

For some reason, I don't see a package-lock.json that is created after running npm install.

I also tried building a docker image with this, where I notice the warning:

npm notice created a lockfile as package-lock.json. You should commit this file.

...
Step 4/7 : RUN npm install
 ---> Running in f4c48bbcc52a
npm notice created a lockfile as package-lock.json. You should commit this file.
...

There may be some obvious configuration that I missed in my local dev environment? Why it won't produce the lock file locally?

Upvotes: 0

Views: 334

Answers (1)

Andrei
Andrei

Reputation: 12036

lock-file was introduced in npm version 5.0.0, you need to update npm to generate lock files

Upvotes: 2

Related Questions