π Search Terms
"Unable to resolve" "Either your platform is unsupported, or you are missing the package on disk."
π Version & Regression Information
- This changed between versions 6.0.3 and 7.0.2
β― Playground Link
No response
π» Code
npm package.json specifies typescript ^7.0.2:
{
...,
"devDependencies": {
...
"typescript": "^7.0.2",
...
}
}
npm package-lock.json generated via:
npm install --package-lock-only
Then, dependencies installed via
npm ci --omit=optional --ignore-scripts
Finally, typescript executed via a command like:
npm exec --no --offline --package typescript -- 'tsc' --target ES2016 --module ES2015 --moduleResolution bundler --allowSyntheticDefaultImports true --strict --outDir /some/directory /some/typescript/file.ts
(A much simpler command would have the same effect!)
π Actual behavior
Typescript command fails with the following error:
file:///some/directory/node_modules/typescript/lib/getExePath.js:53
throw new Error("Unable to resolve " + platformPackageName + ". Either your platform is unsupported, or you are missing the package on disk.");
^
Error: Unable to resolve @typescript/typescript-linux-x64. Either your platform is unsupported, or you are missing the package on disk.
at getExePath (file:///some/directory/node_modules/typescript/lib/getExePath.js:53:19)
at file:///some/directory/node_modules/typescript/lib/tsc.js:6:13
at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
at async node:internal/modules/esm/loader:643:26
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)
π Expected behavior
Typescript command completes without error, as it does if the process is repeated with version ^6.0.3 in package.json.
Additional information about the issue
I'm not sure whether this is an actual bug, or just a change in the way typescript handles dependencies between version 6 and 7, whereby it did not rely on optional dependencies at version 6, but does rely on platform-specific optional dependencies at version 7. My understanding of optional dependencies is that they are for dependencies that are not necessary for the application to run, so was surprised by this. However, having researched a bit further, it appears that npm may lack support for platform-specific dependencies, and so the issue may be with npm. However, we do not wish to blanket allow optional dependencies in npm just for typescript to work, so our workaround for the moment will be to add @typescript/typescript-linux-x64 as an explicit dependency in our package.json, since our application will only be run on Linux. That workaround may not work for other people though.
π Search Terms
"Unable to resolve" "Either your platform is unsupported, or you are missing the package on disk."
π Version & Regression Information
β― Playground Link
No response
π» Code
npm
package.jsonspecifies typescript ^7.0.2:{ ..., "devDependencies": { ... "typescript": "^7.0.2", ... } }npm
package-lock.jsongenerated via:Then, dependencies installed via
Finally, typescript executed via a command like:
(A much simpler command would have the same effect!)
π Actual behavior
Typescript command fails with the following error:
π Expected behavior
Typescript command completes without error, as it does if the process is repeated with version ^6.0.3 in
package.json.Additional information about the issue
I'm not sure whether this is an actual bug, or just a change in the way typescript handles dependencies between version 6 and 7, whereby it did not rely on optional dependencies at version 6, but does rely on platform-specific optional dependencies at version 7. My understanding of optional dependencies is that they are for dependencies that are not necessary for the application to run, so was surprised by this. However, having researched a bit further, it appears that npm may lack support for platform-specific dependencies, and so the issue may be with npm. However, we do not wish to blanket allow optional dependencies in npm just for typescript to work, so our workaround for the moment will be to add
@typescript/typescript-linux-x64as an explicit dependency in ourpackage.json, since our application will only be run on Linux. That workaround may not work for other people though.