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

Installer throws ERR_REQUIRE_ESM when making a clean install #3044

Closed
kluplau opened this issue May 1, 2022 · 14 comments
Closed

Installer throws ERR_REQUIRE_ESM when making a clean install #3044

kluplau opened this issue May 1, 2022 · 14 comments

Comments

@kluplau
Copy link

kluplau commented May 1, 2022

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'
}
@pollingj
Copy link

pollingj commented May 1, 2022

Just to confirm, I'm having the same issue as well.

@kluplau
Copy link
Author

kluplau commented May 1, 2022

I tried to reinstall node, reboot machine, and install an earlier version of the installer, but with no luck.

@pollingj
Copy link

pollingj commented May 1, 2022

It's because the latest version of sort-package-json is using ESM

@chungweileong94
Copy link

It's because the latest version of sort-package-json is using ESM

Yeah, the latest package is causing the ESM error
https://github.com/keithamus/sort-package-json/compare/v1.55.0...v1.56.0?short_path=b335630#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5

@byhemechi
Copy link

byhemechi commented 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

@pSnehanshu
Copy link

Facing the same issue here.

@thisislawatts
Copy link

Yep, looks like this change from sort-package-json should have been a breaking change but unfortunately semantic release can be a little hard to work with here. 😓
keithamus/sort-package-json#256 (comment)

thisislawatts added a commit to thisislawatts/remix that referenced this issue May 1, 2022
The most recent release to sort-package-json switched
to ESM format. This is a breaking change which has
not been released with an appropriate version, for example 2.x

The intention of this change is to explicitly pin the package
version and avoid the incompatible v1.56.0 being installed

Closes remix-run#3044
thisislawatts added a commit to thisislawatts/remix that referenced this issue May 1, 2022
The most recent release to sort-package-json switched
to ESM format. This is a breaking change which has
not been released with an appropriate version, for example 2.x

The intention of this change is to explicitly pin the package
version and avoid the incompatible v1.56.0 being installed

Closes remix-run#3044
@ByronBos
Copy link

ByronBos commented May 1, 2022

Easiest fix in the short term to is to override the version in your package.json, got my project back up and running.

"overrides": { "sort-package-json": "1.55.0" }

@rabilrbl
Copy link

rabilrbl commented May 1, 2022

Easiest fix in the short term to is to override the version in your package.json, got my project back up and running.

"overrides": { "sort-package-json": "1.55.0" }

I am unable to run create-remix for init template.

@ByronBos
Copy link

ByronBos commented May 1, 2022

Ah yes apologies, my comment is for existing projects you might be trying to work with.
I would guess the fix @byhemechi mentioned would be the only immediate fix for that.

You could potentially clone one of the examples from https://github.com/remix-run/remix/tree/main/examples and then add the override as another way to get going.

@garth
Copy link

garth commented May 1, 2022

I reported the issue here keithamus/sort-package-json#258

@kukuricapolna
Copy link

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

thanks this works

@cslz4
Copy link

cslz4 commented May 1, 2022

Thanks guys! Here instead of "overrides": { "sort-package-json": "1.55.0" } i got it working by adding "resolutions": { "sort-package-json": "1.55.0" } to my package.json. Just remember to delete node_modules and run yarn or npm i again.

@keithamus
Copy link

This should be fixed in v1.56.1

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

Successfully merging a pull request may close this issue.