Closed typescript-bot closed 1 year ago
Hello! I have this error too in my project:
Typescript 5.2.2 gives the error:
tsconfig.json:28:15 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'.
28 "module": "es2022", /* Specify what module code is generated. */
~~~~~~~~
Code was previously working with typescript 5.1.6 and reverting the typescript version fixes the error. Heres my settings:
tsconfig.json
{
"compilerOptions": {
"target": "es2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"module": "es2022", /* Specify what module code is generated. */
"moduleResolution": "node16", /* Specify how TypeScript looks up a file from a given module specifier. */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": [
"src/"
]
}
I am also getting this Node16 issue with the latest TypeScript version. Does anyone have any ideas on how to fix it?
EDIT: After some digging I seem to have fixed it. I just set the moduleResolution in my TSConfig to nodenext. The links which helped me out are the following: https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/#module-and-moduleresolution-must-match-under-recent-node-js-settings https://github.com/microsoft/TypeScript/pull/54567 https://www.typescriptlang.org/tsconfig#moduleResolution https://github.com/cheeriojs/cheerio/pull/3251/files
The following errors were reported by 5.3.0-dev.20230820, but not by 5.1.6 Pipeline that generated this bug Logs for the pipeline run File that generated the pipeline
This run considered 200 popular TS repos from GH (after skipping the top 0).
Successfully analyzed 112 of 200 visited repos
| Outcome | Count | |---------|-------| | Detected interesting changes | 14 | | Detected no interesting changes | 98 | | Git clone failed | 2 | | Package install failed | 30 | | Project-graph error in old TS | 5 | | Too many errors in old TS | 46 | | Unknown failure | 5 |Investigation Status