简体   繁体   English

NPM CI 和 Bluebird 承诺警告

[英]NPM CI and Bluebird promise warnings

Short intro : We are starting to use npm ci for a more reliable installation of dependencies for our react application, instead of install .简短介绍:我们开始使用 npm ci来为我们的 React 应用程序更可靠地安装依赖项,而不是install But we have been noticing some strange promise rejection behavior when using ci .但是我们在使用ci时注意到了一些奇怪的承诺拒绝行为。


Description: When running npm ci in a node environment with NODE_ENV set to development , we receive hundreds of promise warnings from the Bluebird promise library:描述:当在NODE_ENV设置为development的节点环境中运行 npm ci时,我们会收到来自 Bluebird 承诺库的数百条承诺警告:

(node:95984) Warning: .then() only accepts functions but was passed: [object Object]

I am curious whether these are coming from npm CI's code itself, as we have never seen these errors except when using npm CI.我很好奇这些是否来自 npm CI 的代码本身,因为我们从未见过这些错误,除非使用 npm CI。

You can also see in their source code that NPM is using Bluebird Promise library version 3.5.3 .您还可以在他们的源代码中看到 NPM 使用的是 Bluebird Promise 库版本3.5.3

To test this, I have incrementally removed all of the main and dev dependencies in our package.json, generating lock files and running npm ci to see if it originated from any specific packages, but it occurred every single time down to the last package (and alternate single packages).为了测试这一点,我逐渐删除了 package.json 中的所有 main 和 dev 依赖项,生成锁定文件并运行npm ci以查看它是否源自任何特定的包,但它每次都发生到最后一个包(和备用单包)。

I have also created an entirely separate npm repo and installed a package (react-scripts@latest), generated a lock file, and on running npm ci received the same promise warnings.我还创建了一个完全独立的 npm repo 并安装了一个包 (react-scripts@latest),生成了一个锁定文件,并且在运行npm ci收到了相同的承诺警告。

We were able to silence the errors on build by setting the environment variable BLUEBIRD_PROMISES=0 per the recommendations of this npm issue , and this did silence the warnings.我们能够通过根据此npm 问题的建议设置环境变量BLUEBIRD_PROMISES=0来消除构建错误,这确实消除了警告。 But we would like to know why this is happening, and if there is something underlying these warnings that deserves more attention than simply silencing them.但是我们想知道为什么会发生这种情况,以及这些警告背后是否有值得更多关注的东西,而不是简单地使它们保持沉默。

Version info:版本信息:
npm: 6.4.1 npm: 6.4.1
node: 10.15.0节点: 10.15.0

I totally missed this (almost year old) question :]我完全错过了这个(几乎一岁)的问题:]

But we would like to know why this is happening,但我们想知道为什么会这样,

Bluebird has a warning feature where it warns against incorrect usage of promises. Bluebird 有一个警告功能,它可以警告不正确使用 promise。 NPM uses bluebird internally and NPM has incorrect usage inside its own code base at some places. NPM 在内部使用 bluebird,并且 NPM 在其自己的代码库中的某些地方使用不正确。

The particular warning happens when you .then with a non-function which is likely an error.当您.then使用可能是错误的非函数时.then会发生特定警告

and if there is something underlying these warnings that deserves more attention than simply silencing them.如果这些警告背后有什么东西值得更多关注,而不是简单地使它们沉默。

You can silence them in general with environment variables or safely ignore them.您通常可以使用环境变量使它们静音或安全地忽略它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM