作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用带有 gulp 的 Node 来运行一些构建任务。这一直很好,直到几天前。现在(我假设在升级/更新之后,不确定哪个具体。我相信这是 Node 从 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 所以我找不到触发它的原因。
pipeline
至
.pipe
,更新 Node 和依赖关系,使用
async/await
,而其他一些细微的变化并没有让我更接近缩小问题的范围。
clean_fake
) 不会触发警告 gulp clean
和 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;
当前版本:
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)
最佳答案
这是 known issue在 Node 14.5.0 中由 Gulp 依赖 async-done
引起使用已弃用的 domain
显示此警告的模块。
根据链接的 Gulp 问题中的一篇文章,在 Gulp 使用相关代码的上下文中,弃用错误不是故意的。
在 Node 14.6.0 中,不再为所有 Gulp 任务任务显示此警告(如果您的代码以不推荐的方式使用模块,您的自定义代码可能会触发警告)。
关于node.js - 运行 gulp 任务时如何解决 "Using a domain property in MakeCallback is deprecated"警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63011636/
我是一名优秀的程序员,十分优秀!