Node.js syntax error when trying to run myst-to-md
example
#981
-
This is my first time using Node.js so please forgive this totally noob question 😇 I'm trying to run the
But I'm getting a SyntaxError:
There are of course numerous references in StackOverflow and the like to this problem, but my |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @astrojuanlu, I put together a repo and video tutorial here: The node ecosystem can be really tough to get up and running with, so hopefully that template can cut through some of the noise and get you to actually playing with something a bit faster! This uses I put a few demos in that repo, and created a rough walkthrough video, that maybe can get you up and running. Maybe that repo turns into something more with some prompting from you!? Best of luck, happy to answer more questions!! |
Beta Was this translation helpful? Give feedback.
-
After reading around a bit, I think This is how "main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
// ...
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
}
}, However, I note that:
This is probably the reason why I'm getting a warning (and then a What the TypeScript docs do instead is using a specific extension to separate CommonJS from ESM: // package.json
{
"name": "my-package",
"type": "module",
"exports": {
".": {
// Entry-point for `import "my-package"` in ESM
"import": "./esm/index.js",
// Entry-point for `require("my-package") in CJS
"require": "./commonjs/index.cjs",
},
},
// CJS fall-back for older versions of Node.js
"main": "./commonjs/index.cjs",
} Therefore, even though I have little experience with the Node.js ecosystem, I think there are essentially 3 ways forward:
I'd send a pull request myself but I considered it would be good to discuss it here first. Thoughts? |
Beta Was this translation helpful? Give feedback.
Making some progress on moving to ESM only @astrojuanlu!
jupyter-book/mystmd#417
I moved from
jest
-->vitest
, which allowed us to sidestep all of the nonsense related to jest and cjs. I think this will help things out, but might be a bit bumpy as we figure out some downstream packaging issues.