运行 npm install 不产生锁文件

Running npm install does not produce lock file

当运行npm install时,它什么时候会产生一个package-lock.json文件,什么时候不会?

这是我使用的 npm 版本:

$ npm --version
3.10.10

这是我正在测试的一个简单 package.josn

$ 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": "..."
}

出于某种原因,我没有看到在 运行 npm install 之后创建的 package-lock.json

我也尝试用这个构建一个 docker 图像,我注意到警告:

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.
...

我在本地开发环境中可能遗漏了一些明显的配置?为什么它不会在本地生成锁定文件?

lock-file是npm 5.0.0版本引入的,需要更新npm才能生成锁文件