react-email icon indicating copy to clipboard operation
react-email copied to clipboard

After running the "email dev" command, an error occurs

Open Vladimir-Urik opened this issue 3 years ago • 5 comments

Describe the Bug

After running the "email dev" command, an error occurs.

Which package is affected (leave empty if unsure)

No response

Link to the code that reproduces this issue

To Reproduce

Computer info: Actual OS: win32 Actual Arch: x64

Steps to reproduce:

1. Type "yarn dev" after installation

yarn run v1.22.19
$ email dev
D:\.dev\reactjs\safetalk-emails\node_modules\ora\index.js:7
const stripAnsi = require('strip-ansi');
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module D:\.dev\reactjs\safetalk-emails\node_modules\strip-ansi\index.js from D:\.dev\reactjs\safetalk-emails\node_modules\ora\index.js not supported.
Instead change the require of D:\.dev\reactjs\safetalk-emails\node_modules\strip-ansi\index.js in D:\.dev\reactjs\safetalk-emails\node_modules\ora\index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (D:\.dev\reactjs\safetalk-emails\node_modules\ora\index.js:7:19)
    at Object.<anonymous> (D:\.dev\reactjs\safetalk-emails\node_modules\react-email\dist\source\utils\generate-email-preview.js:10:31)
    at Object.<anonymous> (D:\.dev\reactjs\safetalk-emails\node_modules\react-email\dist\source\utils\index.js:20:14)
    at Object.<anonymous> (D:\.dev\reactjs\safetalk-emails\node_modules\react-email\dist\source\commands\dev.js:7:17)
    at Object.<anonymous> (D:\.dev\reactjs\safetalk-emails\node_modules\react-email\dist\source\index.js:8:15) {
  code: 'ERR_REQUIRE_ESM'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected Behavior

Start the dev environment.

What's your node version? (if relevant)

v16.16.0

Vladimir-Urik avatar Nov 15 '23 00:11 Vladimir-Urik

Hi,

How did you solve this issue ?

Isos9 avatar Nov 15 '23 22:11 Isos9

Managed to find a workaround:

  • Run initial yarn which will create a yarn.lock file.
  • Then run yarn dev which will create the .react-email folder.
  • Quit and at this point it will not start again.
  • Delete yarn.lock and run yarn again.
  • Run yarn dev

This works with react-email version 1.9.5 node version 18.16.0 and as a standalone version. cc: @Isos9

vykintas-z avatar Nov 16 '23 11:11 vykintas-z

For me, deleting yarn.lock and node_modules + reinstalling packages was the fix.

zachgoll avatar Nov 17 '23 19:11 zachgoll

It fixes it once, however, when trying to run email dev a second time, it fails with the original error message

dan-scrumsdotcom avatar Dec 12 '23 08:12 dan-scrumsdotcom

Managed to find a workaround:

* Run initial `yarn` which will create a `yarn.lock` file.

* Then run `yarn dev` which will create the `.react-email` folder.

* Quit and at this point it will not start again.

* Delete `yarn.lock` and run `yarn` again.

* Run `yarn dev`

This works with react-email version 1.9.5 node version 18.16.0 and as a standalone version. cc: @Isos9

This an issue with yarn https://github.com/eslint/eslint/discussions/17215#discussioncomment-6511704

gabrielmfern avatar Jan 17 '24 07:01 gabrielmfern