question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installer throws ERR_REQUIRE_ESM when making a clean install

See original GitHub issue

What version of Remix are you using?

latest

Steps to Reproduce

npx create-remix@latest --template remix-run/blues-stack NAME

Expected Behavior

Would install a project in a folder called NAME.

Actual Behavior

It throws an error

➜  projects npx create-remix@latest --template remix-run/blues-stack PROJECT_NAME

Need to install the following packages:
  create-remix@latest
Ok to proceed? (y) y
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
/Users/my-username/.npm/_npx/5164864a48bff686/node_modules/@remix-run/dev/cli/create.js:26
var sortPackageJSON = require('sort-package-json');
                      ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/my-username/.npm/_npx/5164864a48bff686/node_modules/sort-package-json/index.js from /Users/my-username/.npm/_npx/5164864a48bff686/node_modules/@remix-run/dev/cli/create.js not supported.
Instead change the require of index.js in /Users/my-username/.npm/_npx/5164864a48bff686/node_modules/@remix-run/dev/cli/create.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/my-username/.npm/_npx/5164864a48bff686/node_modules/@remix-run/dev/cli/create.js:26:23)
    at Object.<anonymous> (/Users/my-username/.npm/_npx/5164864a48bff686/node_modules/@remix-run/dev/cli/commands.js:29:16)
    at Object.<anonymous> (/Users/my-username/.npm/_npx/5164864a48bff686/node_modules/@remix-run/dev/cli/run.js:24:16)
    at Object.<anonymous> (/Users/my-username/.npm/_npx/5164864a48bff686/node_modules/@remix-run/dev/cli/index.js:15:11)
    at Object.<anonymous> (/Users/my-username/.npm/_npx/5164864a48bff686/node_modules/@remix-run/dev/index.js:15:13)
    at Object.<anonymous> (/Users/my-username/.npm/_npx/5164864a48bff686/node_modules/create-remix/cli.js:14:11) {
  code: 'ERR_REQUIRE_ESM'
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:11
  • Comments:14

github_iconTop GitHub Comments

7reactions
garthcommented, May 1, 2022
6reactions
byhemechicommented, May 1, 2022

A very quick fix is to replace the version of sort-package-json in the npx cache with version 1.55.0

e.g. for the error

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/zsty/.npm/_npx/82f938b29eb562d9/node_modules/sort-package-json/index.js

the problem would be solved with

cd /Users/zsty/.npm/_npx/82f938b29eb562d9/
npm i sort-package-json@1.55.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - How would you fix an 'ERR_REQUIRE_ESM' error?
Make sure to run this in the directory in which your package.json file is in! $ npm install. Use the require() statement like...
Read more >
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
What is this? You can solve the "[ERR_REQUIRE_ESM]: require() of ES Module not supported" by doing one of two things: Use ESM -...
Read more >
Common errors | npm Docs
Broken npm installation; Random errors; No compatible version found ... Some strange issues can be resolved by simply running npm cache clean and...
Read more >
err_require_esm ts-node | The AI Search Engine You Control
Since you're compiling to commonjs modules it will require some transpiling to make them work with ESM. Typescript is adding nodenext as a...
Read more >
Node.js v19.3.0 Documentation
strictEqual(actual, expected[, message]); assert.throws(fn[, error][, message]) ... DEP0086: Remove runInAsyncIdScope; DEP0089: require('node:assert') ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found