相关疑难解决方法(0)

如何从 CommonJS 模块导入 ESM Javascript 文件?咕噜咕噜。错误:[ERR_REQUIRE_ESM]

我的项目完全是作为 CommonJS模块编写的,我不打算更改它。问题是我在使用gulp.

出现这种情况的文件:

const { dest, src } = require('gulp')
const imagemin = require('gulp-imagemin') // This is a ESM. Compiler gives error [ERR_REQUIRE_ESM]


const images = () => {
    // We have specific configs for jpeg and png files to try
    // to really pull down asset sizes
    return src('./src/images/**/*')
        .pipe(
            imagemin(
                [
                    imagemin.mozjpeg({ quality: 60, progressive: true }),
                    imagemin.optipng({ optimizationLevel: 5, interlaced: null })
                ],
                {
                    silent: true
                }
            )
        ) …
Run Code Online (Sandbox Code Playgroud)

javascript node.js gulp

6
推荐指数
1
解决办法
8222
查看次数

标签 统计

gulp ×1

javascript ×1

node.js ×1