module-alias
module-alias copied to clipboard
Doesn't work on node v18.12.1?
index.js
require('module-alias/register')
...
package.json
{
...
"_moduleAliases": {
"#root": "./",
"#src": "./src",
"#routes": "./src/routes",
"#lib": "./src/lib",
"#utils": "./src/lib/utils",
"#models": "./src/lib/models",
"#decors": "./src/lib/decors",
"#schemas": "./src/lib/schemas"
}
...
}
versions
node: v18.21.1 module-alias: 2.2.2
and the error??
@qxb3 How did you resolve this issue? In case of mine It throws Can't Find module ?
node:internal/modules/cjs/loader:1042
throw err;
^
Error: Cannot find module '@routersV1/users/usersRouter'
package.json
"_moduleAliases": {
"@routersV1/*": "./src/routers/v1/*"
}
Nodejs: v18.13.0
@girixcode7 i didn't i instead use this: #113
Follow this: https://medium.com/zero-equals-false/how-to-use-module-path-aliases-in-visual-studio-typescript-and-javascript-e7851df8eeaa
You might be missing the aliases in tsconfig.json