NodeJS [DEP0097]弃用警告:

时间:2019-06-04 08:40:37

标签: node.js gulp babeljs

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

  

(节点:6692)[DEP0097] DeprecationWarning:在以下位置使用域属性   不建议使用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"
  }

我应该升级/添加什么?

3 个答案:

答案 0 :(得分: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.

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

这是运行时特定的节点v10问题。  我不知道弃用在何处显示,但大多数情况下是在异步/等待和承诺代码上。

答案 1 :(得分:0)

面临类似问题:  手动订购 (节点:13628)[DEP0097] DeprecationWarning:不建议在MakeCallback中使用domain属性。请改用MakeCallback的async_context变体或AsyncResource类。

1)未处理的诺言拒绝:

  TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"
  at new ClientRequest (_http_client.js:119:11)
  at Object.request (http.js:42:10)

答案 2 :(得分:0)

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

run{ skipUncaughtErrors: true }