【问题标题】:NodeJS [DEP0097] DeprecationWarning:NodeJS [DEP0097] 弃用警告:
【发布时间】:2019-06-04 08:40:37
【问题描述】:

你能帮我解决这个错误吗?

(node:6692) [DEP0097] DeprecationWarning: Using a domain property in 不推荐使用 MakeCallback。使用 async_context 变体 改用 MakeCallback 或 AsyncResource 类。未处理的拒绝 插件“webpack-stream”中的错误

代码是

import gulp from 'gulp';
import yargs from 'yargs';
import sass from 'gulp-sass';
import cleanCSS from 'gulp-clean-css';
import gulpif from 'gulp-if';
import sourcemaps from 'gulp-sourcemaps';
import imagemin from 'gulp-imagemin';
import del from 'del';
import webpack from 'webpack-stream';  

export const scripts = () => {
    return gulp.src(paths.scripts.src)
    .pipe(webpack({
        module: {
            rules: [{
                test: /\.js$/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
                }]
        },
        output : {
            filename: 'bundle.js'
        }
    }))
    .pipe(gulp.dest(paths.scripts.dest));
} 

并来自 package.json:

    "devDependencies": {
    "@babel/core": "^7.4.5",
    "@babel/preset-env": "^7.4.5",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "^1.7.0",
    "babel-register": "^6.26.0",
    "del": "^4.1.1",
    "gulp": "^4.0.2",
    "gulp-clean-css": "^4.2.0",
    "gulp-if": "^2.0.2",
    "gulp-imagemin": "^6.0.0",
    "gulp-sass": "^4.0.2",
    "gulp-sourcemaps": "^2.6.5",
    "node-sass": "^4.12.0",
    "webpack": "^4.32.2",
    "webpack-stream": "^5.2.1",
    "yargs": "^13.2.4"
  }

我应该升级/添加什么?

【问题讨论】:

    标签: node.js gulp babeljs


    【解决方案1】:

    我的朋友让我解决这个问题,但我无法用我的系统重新生成这个问题。

    直到我找到这个Doc

    DEP0097: MakeCallback with domain property#
    node v10.0.0
    Runtime deprecation.
    Type: Runtime
    
    Users of MakeCallback that add the domain property to carry context, should start 
    using the async_context variant of MakeCallback or CallbackScope, or the 
    high-level AsyncResource class.
    

    然后通过升级和降级更改节点版本后,它工作正常,没有错误。

    这是运行时特定的 node v10 问题。 我不知道从哪里弃用,但大多数时候它是在 async/await 和 promise 代码上。

    【讨论】:

      【解决方案2】:

      此解决方案有效。使用以下运行选项:

      run{ skipUncaughtErrors: true }

      【讨论】:

      • 目前这种东西“有效”。但是“不推荐使用”意味着最终它警告您的事情将完全停止工作(在更高版本的 Node 中)。因此,最好找出问题的真正原因并加以解决。
      猜你喜欢
      • 2023-04-07
      • 2020-07-20
      • 2022-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-11
      • 2021-07-12
      相关资源
      最近更新 更多