我正在使用带有 gulp 的节点来运行一些构建任务。直到几天前,这一切都还顺利。现在(我假设在升级/更新后,不确定是哪一个。我相信这是节点从 14.4 更新到 14.5)我不断收到此警告
[DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
我不知道如何使用--trace-deprecation
与 gulp 所以我找不到触发它的原因。
我的实际gulpfile更长并且注释掉部分,改变pipeline
to .pipe
,更新节点和依赖项,使用async/await
,以及其他一些小的改变并没有让我更进一步缩小问题的范围。
因此,我在下面设置了这个最小的工作示例:
- 运行默认的 gulp 任务(
clean_fake
) 不会触发警告
- both
gulp clean
and gulp styles
导致警告显示
const gulp = require('gulp');
const del = require('del');
const sass = require('gulp-sass');
async function clean() {
const deletedPaths = await del([ './js/*.site.js', './style.css' ], { dryRun: true });
console.log('Deleted files and directories:\n', deletedPaths.join('\n'));
}
async function clean_fake() {
const deletedPaths = await test();
console.log('Deleted files and directories:\n', deletedPaths.join('\n'));
}
function test() {
console.log('dummy function');
return [ 'test' ];
}
function styles() {
return gulp.src('./src/sass/style.scss').pipe(sass()).pipe(gulp.dest('./'));
}
exports.clean = clean;
exports.styles = styles;
exports.default = clean_fake;
当前版本:
节点:v14.5.0
npm:6.14.6
删除:5.1.0
吞咽:4.0.2
gulp-sass:4.1.0
PS:还有这个类似的question https://stackoverflow.com/questions/56440304/nodejs-dep0097-deprecationwarning,但没有解决我的问题。
Update:
我想出了如何通过运行来跟踪弃用NODE_OPTIONS
:
NODE_OPTIONS='--trace-deprecation' gulp
然而输出对我没有多大帮助
(node:146806) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
at emitMakeCallbackDeprecation (domain.js:123:13)
at FSReqCallback.topLevelDomainCallback (domain.js:134:5)
at FSReqCallback.callbackTrampoline (internal/async_hooks.js:121:14)