Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fail when using Babel #146

Closed
kirvedx opened this issue Jul 20, 2022 · 3 comments
Closed

Build fail when using Babel #146

kirvedx opened this issue Jul 20, 2022 · 3 comments

Comments

@kirvedx
Copy link

kirvedx commented Jul 20, 2022

Issue

After upgrading to del v7, there is an error in the build.

What I did

I ran npx npm-check-updates -u and the result was:

Upgrading /home/rik/workspaces/kwaeri/node-kit/filesystem/package.json
[====================] 23/23 100%

 @babel/cli                                  ^7.17.6  →  ^7.18.9
 @babel/core                                 ^7.17.5  →  ^7.18.9
 @babel/plugin-proposal-object-rest-spread   ^7.17.3  →  ^7.18.9
 @babel/plugin-proposal-optional-chaining    ^7.16.7  →  ^7.18.9
 @babel/preset-env                          ^7.16.11  →  ^7.18.9
 @babel/register                             ^7.17.0  →  ^7.18.9
 @types/mocha                                 ^9.1.0  →   ^9.1.1
 @types/node                                ^17.0.20  →  ^18.0.6
 del                                          ^6.0.0  →   ^7.0.0
 mocha                                        ^9.2.1  →  ^10.0.0
 typescript                                   ^4.5.5  →   ^4.7.4

Run npm install to install new versions.

I then did subsequently run npm install

The Error

After running npm run build && npm run test, I received the following:

```bash
> gulp clean && gulp

[14:32:27] Requiring external module @babel/register
/home/rik/workspaces/kwaeri/node-kit/filesystem/gulpfile.babel.js:141
    }
      ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/rik/workspaces/kwaeri/node-kit/filesystem/node_modules/del/index.js from /home/rik/workspaces/kwaeri/node-kit/filesystem/gulpfile.babel.js not supported.
Instead change the require of index.js in /home/rik/workspaces/kwaeri/node-kit/filesystem/gulpfile.babel.js to a dynamic import() which is available in all CommonJS modules.

The problem

The suggestion says I should change require of ES Module to an Import. However, this is already the case. See my Gulpfile:

import del from 'del';

I use Babel for ES6 support. So, I've named my file gulpfile.babel.js, and I have a .babelrc file in the root of the project with the following contents:

{
    "presets": ["@babel/preset-env"],
    "env":
    {
        "test":
        {
            "plugins":
            [
                ["istanbul"],
                ["@babel/plugin-proposal-object-rest-spread"]
            ]
        },
        "development":
        {
            "plugins":
            [
                ["istanbul"],
                ["@babel/plugin-proposal-object-rest-spread"]
            ]
        }
    }
}

Other Information

I'm current running:

  • Debian Linux Bookworm - kernel 5.18.0-2-amd64
  • Node version 18.6.0
  • NPM version 8.13.2

Environment:

I have NODE_OPTIONS=--no-experimental-fetch setup when terminal program is "vscode" within my .bashrc ⇨ simply because Node v18 brought some changes that require that for most of my modules.

Current Resolution

I've reverted to del v6

"del": "^6.0.0"

Conclusion

I'd like to know if this is something I'm failing to attend in some other fashion - or if this is an issue with the latest release (v7).

@sindresorhus
Copy link
Owner

This package is now pure ESM. Please read this. - https://github.com/sindresorhus/del/releases/tag/v7.0.0

@jpike88
Copy link

jpike88 commented Sep 28, 2022

@kirvedx just use rimraf instead, it will do the same job and you won't be subject to this weird ESM crusade.

@kirvedx
Copy link
Author

kirvedx commented Oct 3, 2022

@jpike88 Appreciate the mention - Thanks.

I mindlessly - and lazily - reported Del wasn't working with Gulp and continued working without updating it. I'm working with a collection of 40+ modules and really just wanted to avoid deviating into module template management at the time; but I've since done so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants