Closed chigix closed 6 years ago
@chigix Are you sure u can use moduleResolution "classic" with node.js?
Because I compile to es6 modules, moduleResolution is defaultly set as classic through typescript document. Although there seems no problem to use es6 module on node.js, is it recommended to actually set module resolution as node
manually?
u can't use es6 modules
in node.js just yet, so u have to compile your ts code to commonjs.
{
...
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"noUnusedLocals": true,
"outDir": "dist",
"sourceMap": true,
"target": "es6"
},
...
}
Remember node.js right now has all es6 features except es6 module.
OK, I got it and thanks for your advice.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I'm submitting a...
Current behavior
Because I need to use path mapping support for es6 module,
moduleResolution
intsconfig.json
is set asclassic
. Then errors about unable resolving modules appear in building task:Expected behavior
No module resolution error when typescript module resolution strategy set as
classic
.Minimal reproduction of the problem with instructions
Directly make one modification in official starter project: https://github.com/nestjs/typescript-starter
Add
"moduleResolution": "classic"
intotsconfig.json
Or add
"module": "es6"
instead.What is the motivation / use case for changing the behavior?
Although I could write whole path to export file under
@nestjs
innode_modules
folder, but it is not convenient and not friendly for IDE (Which I am using is VSCode).Environment