如何锁定云函数中的 npm 依赖项
How to lock down npm dependencies in a cloud function
有什么方法可以控制部署云函数时安装的依赖项(和临时依赖项)的版本?
自 cloud function runtime uses node v6.11.5
, I assume it is using npm v3.10.10
distributed with that version of node. This version of npm does not support package.lock
(added in npm v5.0.0
).
我在我的 package.json
中将所有版本设置为固定版本(删除 ^
)并将 save-exact=true
添加到我的 .npmrc
文件中,但这只会直接控制依赖项。瞬时依赖性不会以这种方式锁定。
有什么方法可以控制云函数中所有安装的依赖版本吗? npm shrinkwrap.json
荣幸了吗?
npm-shrinkwrap.json
和 package-lock.json
仅从 NPM 包的角度来看 author/mantainer
package-lock.json
不会发布到 NPM 注册表 (但它将保留在源代码中) 和保证项目的任何 author/mantainer 将获得 相同的依赖关系.
npm-shrinkwrap.json
意味着 将发布到 NPM 注册表并保证 不仅 authors/mantainers而且安装软件包的用户也会得到相同的依赖关系。
由于您的项目与编写 NPM 包无关,因此您可以依靠 npm-shrinkwrap.json
使用任何 NPM
版本获得可重现的依赖关系树。
我发布了 a question in the Cloud Functions Beta Testers 组,他们确认 npm-shrinkwrap.json
在部署到 Cloud Functions 时不被接受。
产品经理的回复:
Currently, we don't support the npm-shrinkwrap.json file. We're looking at making some improvements to dependency management as we think about our runtime strategy, and this is a suggestion that we'll definitely consider.
按照他们的建议,我在他们的 public 问题跟踪器上创建了 an issue。如果这也是您想要的,请添加您对该问题的支持(通过加注星标)!
作为高级 node.js 开发人员,拥有可重现安装的方法对于交付具有生产价值的代码至关重要。
有什么方法可以控制部署云函数时安装的依赖项(和临时依赖项)的版本?
自 cloud function runtime uses node v6.11.5
, I assume it is using npm v3.10.10
distributed with that version of node. This version of npm does not support package.lock
(added in npm v5.0.0
).
我在我的 package.json
中将所有版本设置为固定版本(删除 ^
)并将 save-exact=true
添加到我的 .npmrc
文件中,但这只会直接控制依赖项。瞬时依赖性不会以这种方式锁定。
有什么方法可以控制云函数中所有安装的依赖版本吗? npm shrinkwrap.json
荣幸了吗?
npm-shrinkwrap.json
和 package-lock.json
package-lock.json
不会发布到 NPM 注册表 (但它将保留在源代码中) 和保证项目的任何 author/mantainer 将获得 相同的依赖关系.
npm-shrinkwrap.json
意味着 将发布到 NPM 注册表并保证 不仅 authors/mantainers而且安装软件包的用户也会得到相同的依赖关系。
由于您的项目与编写 NPM 包无关,因此您可以依靠 npm-shrinkwrap.json
使用任何 NPM
版本获得可重现的依赖关系树。
我发布了 a question in the Cloud Functions Beta Testers 组,他们确认 npm-shrinkwrap.json
在部署到 Cloud Functions 时不被接受。
产品经理的回复:
Currently, we don't support the npm-shrinkwrap.json file. We're looking at making some improvements to dependency management as we think about our runtime strategy, and this is a suggestion that we'll definitely consider.
按照他们的建议,我在他们的 public 问题跟踪器上创建了 an issue。如果这也是您想要的,请添加您对该问题的支持(通过加注星标)!
作为高级 node.js 开发人员,拥有可重现安装的方法对于交付具有生产价值的代码至关重要。