Compile error after upgrading to 2.0.0 using TypeScript
See original GitHub issueDescribe the bug I get the following error after building the project with the new 2.0.0 version.
[ERROR] 11:38:21 Error: Must use import to load ES Module: /Users/robin/Projects/games/dogfight-online/node_modules/@geckos.io/server/lib/index.js
require() of ES modules is not supported.
require() of /Users/robin/Projects/games/dogfight-online/node_modules/@geckos.io/server/lib/index.js from /Users/robin/Projects/games/dogfight-online/server/src/index.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/robin/Projects/games/dogfight-online/node_modules/@geckos.io/server/package.json.
I’m importing as follows:
import geckos from "@geckos.io/server";
I use ts-node-dev
to compile my project as I’m in a TypeScript environment.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Typescript compile errors after upgrading react native project
and It seems like the typescript packages are not compatible with their original packages. package.json dependencies "react": "17.0.2", "react- ...
Read more >Migrating to AWS CDK v2 - AWS Documentation - Amazon.com
If you're using the CDK v2 Developer Preview, you have dependencies in your project on a Release Candidate version of the AWS CDK,...
Read more >Working with JavaScript in Visual Studio Code
You are working with JavaScript or TypeScript code on vscode.dev or github.dev and VS Code is running in the browser. You open a...
Read more >ts-node - npm
It is important to differentiate between errors from ts-node, errors from the TypeScript compiler, and errors from node . It is also important ......
Read more >Documentation - TypeScript 3.9
When a line is preceded by a // @ts-expect-error comment, TypeScript will ... are in the middle of an upgrade between two different...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Would it be possible to ship two versions: an ESM one and a CJS one to have something like the below?
I think this would be useful for devs who are using a build system that outputs CJS.
Why? It is working fine. You just have to learn how to use ECMAScript modules in Node.js.