Following tutorials and screwed something up

#1

This isn’t really a Node issue.
In the future you can post questions like this to the @std/esm repo.

You’re getting the error

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: 

because you need to opt-in to the @std/esm loader by making it a dep or by adding its options object to the package.json of apple.mjs. So after doing `**

npm i --save @std/esm`

** , when you run

node -r @std/esm apple.mjs

You’ll get

/path/to/kale.js:1
export function kale() {}
^

SyntaxError: 'import' and 'export' may only be used in ES modules
    at /path/to/banana.mjs

This is because, by default, @std/esm follows Nodes proposed module rules.
To unlock CJS compat you simply add this option to your package.json

@std/esm”: “cjs”

Then node -r @std/esm apple.mjs will run without error.

I only got as far as this “npm i --save @std/esm” line. Now atom wont start and my filepaths are all screwed up again.

anything I can do?

#2

all screwed up again.

What do you mean “again”? It looks like you have copied someone else’s answer from a different site (GitHub?), but there’s no context for your original issue. Where are you running npm? What file paths are you talking about? Before we can tell you what to do, we need to know everything.

#3

@DamnedScholar I fixed it. I wound up having to delete all the atom folders and re install. and yeah, I was trying to do something totally different when i entered that command and it basically just made it so that atom wouldn’t open at all. Not from cmd, and not from the desktop shortcut.

1 Like