Error: No "exports" main defined
See original GitHub issuePlease describe the problem you are having in as much detail as possible:
When trying to use discord-api-types
with TypeScript, I’m getting the following error.
Error: No "exports" main defined in C:\Users\Paul\Desktop\test\node_modules\discord-api-types\package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:413:9)
at packageExportsResolve (node:internal/modules/esm/resolve:652:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.<anonymous> (C:\Users\Paul\Desktop\test\test.ts:1:1)
I tried it first with other code in a project, then a separate file and then a clean project, with a clean install, but the error doesn’t change. I’m sure it’s not me.
Include a reproducible code sample here, if possible:
- Create a new project (folder)
- Run
npm i -s discord-api-types
- Create a file called
test.ts
with the following code.
import { Routes } from "discord-api-types";
console.log(Routes.applicationCommands("123"));
- Run
ts-node test
and see the error.
Further details:
- Runtime:
- Node.js version: v16.7.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (9 by maintainers)
Top Results From Across the Web
No "exports" main resolved in /app/node_modules/@babel ...
With node 12.20.0, node 14.17.4, the error is not thrown. The issue is that a new system for exports has been created, as...
Read more >No "exports" main defined in package.json · Issue #4138 · ipfs ...
ipfs@0.63.x is ESM-only, which means you can't use require to load it, you have to use import . Please see the upgrade guide....
Read more >Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No 'exports'
Run the npm update command to solve the "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No 'exports'" and then run npm audit fix --force if necessary.
Read more >No "exports" main defined - Laracasts
Hello , After cloning my project I got the error bellow when I npm run watch (I deleted the node_modules) ERROR in ./resources/js/app.js...
Read more >How to fix “Error: No valid exports main found for ... - Dev Genius
After some digging around, I found the suggestion to update to Node 14.5. There are many ways to do this; I chose to...
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
Hmm… It seems that I forgot to remove
types
from the package.json, maybe that’s the issue? I think best bet is to wait for TS to implement the nodejsnext targetAnother solution could be to throw an error when importing
discord-api-types
without specifying the version