【问题标题】:Update package.json to reflect installed packages更新 package.json 以反映已安装的包
【发布时间】:2019-01-06 11:40:36
【问题描述】:

假设我的package.json 看起来像这样:

{
  "name": "cool_project",
  "version": "0.0.0",
  "scripts": {
    "start": "node index.js"
  },
  "private": true,
  "dependencies": {
    "rxjs": "^6.0.0"
  }
}

然后在运行npm install 之后,rxjs 的版本是6.6.0

npm ls rxjs
`-- rxjs@6.6.0

现在我可以运行npmyarn 命令来将package.json 中的版本固定到安装的版本吗?

{
  "name": "cool_project",
  "version": "0.0.0",
  "scripts": {
    "start": "node index.js"
  },
  "private": true,
  "dependencies": {
    "rxjs": "6.6.0"
  }
}

这对我很有用,因为如果我想检查我正在使用的包版本,我可以很容易地直接在 package.json 中看到它并将其提交到我的 git repo 历史记录中。

【问题讨论】:

    标签: node.js npm package.json yarnpkg


    【解决方案1】:

    1) 将 package.json 中的每个版本更改为 *

    2) 运行 npm install --save-exact

    【讨论】:

      猜你喜欢
      • 2019-04-09
      • 2015-07-29
      • 1970-01-01
      • 2015-04-18
      • 2018-09-28
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 2018-09-23
      相关资源
      最近更新 更多