I want to use ts-transformer-keys in my typescript project "typescript": "^4.5.5"
. Then I added this dependencies in the typescript package.json
:
"ts-transformer-keys": "^0.4.3",
and added this config in tsconfig.json
like this:
"plugins": [
{ "transform": "ts-transformer-keys/transformer" }
]
but when I import the ts-transformer-keys
in the current project:
import { keys } from 'ts-transformer-keys';
shows error:
Cannot find module 'ts-transformer-keys'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?ts(2792)
why did this happen? what should I do to fix this problem? I have already run the yarn command. the node version is 16.13.2
.
CodePudding user response:
this error message tell how to fix this problem, the typescript default module resolution is classic, this would not search from node_modules
. That why tell you did not found the module that in the node_modules
folder. more info you can read from here: https://www.typescriptlang.org/docs/handbook/module-resolution.html, so fix your problem, try add this config in the tsconfig.json
file:
"moduleResolution":"node",