You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
The error I see is for the first import statement in my require'd file that uses ES modules
node main.js
(function (exports, require, module, __filename, __dirname) { import * as cheerio from 'cheerio';
SyntaxError: Unexpected token import
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:537:28)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
/// build.js
import * as cheerio from 'cheerio';
// ... some other stuff
export function doBuild() {
}
I must be using esm incorrectly?
My aim in using ES modules in node (and thus esm) is to either use tsc to produce ES module .js files from Typescript sources or us ts-node to run everything in memory.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi @jdalton - first: THANK YOU for sharing this great tool.
I too was having issues setting up a small project to use this for my tests (using Tape). This post helped. May I suggest that you use this example in the docs? It was not obvious (until you pointed out here) that I needed to override require locally with what is returned by std/esm :)
/Paul
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The error I see is for the first import statement in my
require
'd file that uses ES modulesnode main.js
I must be using esm incorrectly?
My aim in using ES modules in node (and thus esm) is to either use
tsc
to produce ES module .js files from Typescript sources or usts-node
to run everything in memory.Thanks!
The text was updated successfully, but these errors were encountered: