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

Error [ERR_REQUIRE_ESM]: require() of ES Module [...]/node_modules/.pnpm/[email protected]/node_modules/chalk/source/index.js from [...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/async.js not supported. #2023

Closed
2 of 10 tasks
Anoesj opened this issue Mar 2, 2023 · 3 comments
Assignees

Comments

@Anoesj
Copy link

Anoesj commented Mar 2, 2023

Issue details

Ever since the 2.28.1 update, I get this error. Note that I have "type": "module", in my package.json.
The error message:

Error [ERR_REQUIRE_ESM]: require() of ES Module [...]/node_modules/.pnpm/[email protected]/node_modules/chalk/source/index.js from [...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/async.js not supported.
Instead change the require of index.js in [...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/async.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> ([...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/async.js:7:13)
    at Object.<anonymous> ([...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/async-tasks.js:1:13)
    at Object.<anonymous> ([...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/browser-sync.js:3:18)
    at Object.<anonymous> ([...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/index.js:7:19) {
  code: 'ERR_REQUIRE_ESM'
}

Steps to reproduce/test case

I did not try to create an isolated reproduction, but I expect having "type": "module", in a package.json should do the trick.

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [2.28.1]
  • Node [18]
  • Npm [pnpm v7.28.0]

Affected platforms

Note that I only tested this on Ubuntu.

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

If CLI, please paste the entire command below

n/a

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

browserSync.init({
  server: {
    baseDir: globalThis.paths.src,
    middleware: function (req, res, next) {
      res.setHeader('Access-Control-Allow-Origin', '*');
      next();
    },
  },
  port: 3000,
  single: true,
  https: {
    key: process.env.SSL_LOCALHOST_KEY,
    cert: process.env.SSL_LOCALHOST_CERT,
  },
  open: true,
  ghostMode: false,
  notify: false,
});
@shakyShane shakyShane self-assigned this Mar 4, 2023
@shakyShane
Copy link
Contributor

@Anoesj - can you try [email protected] 🙏🏻

@Anoesj
Copy link
Author

Anoesj commented Mar 4, 2023

Unfortunately, still no luck 😕️:

Error [ERR_REQUIRE_ESM]: require() of ES Module [...]/node_modules/.pnpm/[email protected]/node_modules/chalk/source/index.js from [...]/node_modules/.pnpm/[email protected]/node_modules/eazy-logger/index.js not supported.
Instead change the require of [...]/node_modules/.pnpm/[email protected]/node_modules/chalk/source/index.js in [...]/node_modules/.pnpm/[email protected]/node_modules/eazy-logger/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> ([...]/node_modules/.pnpm/[email protected]/node_modules/eazy-logger/index.js:4:13)
    at Object.<anonymous> ([...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/logger.js:7:14)
    at Object.<anonymous> ([...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/browser-sync.js:7:14)
    at Object.<anonymous> ([...]/node_modules/.pnpm/[email protected]/node_modules/browser-sync/dist/index.js:7:19) {
  code: 'ERR_REQUIRE_ESM'
}

@Anoesj
Copy link
Author

Anoesj commented Mar 4, 2023

Fixed by #2026 ✅️

@Anoesj Anoesj closed this as completed Mar 4, 2023
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

2 participants