Bug Report
🔎 Search Terms
NodeNext, esm, CJS, cli-spinners
🕗 Version & Regression Information
- This only occurs in nightly builds.
- I was unable to test this on prior versions because
nodenext is only supported in the nightly versions.
⏯ Playground Link
From what I can tell you can't install npm modules in the playground, so I made a repro on StackBlitz: https://stackblitz.com/edit/node-opvt9e?file=index.ts run npm run typecheck in the console to see the issue.
💻 Code
importspinnersfrom'cli-spinners';console.log(spinners);
🙁 Actual behavior
TypeScript cannot find the typings for cli-spinners which is a CJS module. It does not use a main or exports or types field in the package.json, it just includes a index.js and index.d.ts file.
index.ts:1:22 - error TS2307: Cannot find module 'cli-spinners' or its corresponding type declarations.
1 import spinners from 'cli-spinners';
~~~~~~~~~~~~~~
Found 1 error in index.ts:1
🙂 Expected behavior
New NodeNext module behaviour to import CJS as it used to. E.g looking at index.d.ts if there is no main field. https://www.typescriptlang.org/docs/handbook/module-resolution.html#how-typescript-resolves-modules
👪 Related
Bug Report
🔎 Search Terms
NodeNext, esm, CJS, cli-spinners
🕗 Version & Regression Information
nodenextis only supported in the nightly versions.⏯ Playground Link
From what I can tell you can't install npm modules in the playground, so I made a repro on StackBlitz: https://stackblitz.com/edit/node-opvt9e?file=index.ts run
npm run typecheckin the console to see the issue.💻 Code
🙁 Actual behavior
TypeScript cannot find the typings for
cli-spinnerswhich is a CJS module. It does not use amainorexportsortypesfield in thepackage.json, it just includes aindex.jsandindex.d.tsfile.🙂 Expected behavior
New
NodeNextmodule behaviour to import CJS as it used to. E.g looking atindex.d.tsif there is nomainfield. https://www.typescriptlang.org/docs/handbook/module-resolution.html#how-typescript-resolves-modules👪 Related
mainfield sindresorhus/cli-spinners#61