Questions tagged [module-alias]
14 questions
8
votes
1 answer
Intellisense for module-alias Package
I am using this npm module (module-alias)
https://www.npmjs.com/package/module-alias in my Node project.
To make use of this package you have to set path aliases in the package.json file.
However, using this package comes with the disadvantage,…

Florian Ludewig
- 4,338
- 11
- 71
- 137
6
votes
2 answers
typescript path alias needs module-alias/register on every file
I am using typescript v3.6.4 with the following tsconfig.json snippet:
"compilerOptions": {
"moduleResolution": "node",
"baseUrl": "./src",
"paths": {
"@config/*": ["config/*"],
"@config": ["config"],
}
}
and module…

jamesdeath123
- 4,268
- 11
- 52
- 93
2
votes
2 answers
Prevent Duplicating Typescript Path Configurations in Monorepo
Gist
I like to follow the "dry" (don't repeat yourself) principle. But currently I have nearly the same path configuration in three different places:
1. Typescript config file
I have a monorepo with multiple Bazel Typescript packages, and thus I…

Florian Ludewig
- 4,338
- 11
- 71
- 137
2
votes
2 answers
How to resolve module not found on Heroku?
I am using module-alias within my nodejs application.
Locally everything works fine, the file path and modules are being found.
However, when deploying on Heroku none of my aliases are being recognized and this error occurs
Error: Cannot find…

andrewoodleyjr
- 2,971
- 2
- 21
- 21
1
vote
0 answers
NodeJs doesn't find aliases folders in build folder when using module-alias/register library
For a couple of days I have been trying to carry out a project where its main structure is:
tsconfig output folder:
./build
/prisma
/master
functions.js
types.js
/src
/Controllers
/Master
…

Angel Mondragon
- 11
- 1
1
vote
1 answer
How to do module aliasing in NodeJS serverless framework
take note: inside src folder
I want to achieve module aliasing name instead of using require("../../services"), require("../../models").
i want to achieve something like this: require("@services"), require("@models");
How to achieve this on…

Poor programmer
- 121
- 12
1
vote
0 answers
How to make sure a "require()" statement is going to be at the top of the transpiled file using babel?
I've got this index.ts file I'm transpiling to index.js with babel.
And I need a specific require to be at the top of the file.
https://www.npmjs.com/package/module-alias
You can see from the module-alias doc that that line should be called one time…

cbdeveloper
- 27,898
- 37
- 155
- 336
1
vote
1 answer
How to add subdirectory module aliases in tsconfig?
I can set module aliases with no issue:
"baseUrl": "./app",
"paths": {
"assets/*": ["assets/*"],
"components/*": ["components/*"],
...
},
This works. However, I (actually my client, who wants to extract some parts of the…

Can Poyrazoğlu
- 33,241
- 48
- 191
- 389
0
votes
0 answers
setup npm package with module alias is failing after build
I am trying to build my project and create an npm package, the built package will be stored in the dist directory, and am using module-alias but the resulting type declarations from the build are not resolving correctly, by showing the following…

Vinicius França
- 101
- 1
- 6
0
votes
0 answers
module-aliases in NPM doesn't work when running unit tests
I defined an alias in package.json:
"_moduleAliases": {
"@microservices": "./microservices",
}
When I use imports such as:
import ClassName from "@microservices/service_name/class_name";
it works when I launch the program.
However, this…

CrazySynthax
- 13,662
- 34
- 99
- 183
0
votes
1 answer
Webpack: bundle typescript module alias with esmodules
I have developed an npm module with Typescript and ES-Modules.
This is the tsconfig.json, in which you can see that there is a path alias. It resides inside the /source folder.
{
"compilerOptions": {
"moduleResolution": "Node16",
…

EuberDeveloper
- 874
- 1
- 14
- 38
0
votes
1 answer
module-alias not working with esm if called from specific file
I want to use module-alias with esm. I have already found an answer here. The problem is that I am using it manually, like this:
import * as path from 'path';
import * as moduleAlias from 'module-alias';
moduleAlias.addAlias('@',…

EuberDeveloper
- 874
- 1
- 14
- 38
0
votes
1 answer
Jest doesn't achieve to import module who imports modules using _moduleAliases
My module imports modules in that manner:
const { Item, Item1 } = require('@v2/helpers');
This is my package.json:
"_moduleAliases": { "@v2/helpers": "src/v2-helpers" }
Then in a test file I try to import a file who imports in the above mentioned…

Raz Buchnik
- 7,753
- 14
- 53
- 96
0
votes
2 answers
Npm library developed with Typescript and module-alias
I am developing an npm library using Typescript as programming language. To develop it comfortably, I used the paths option in tsconfig.json and module-alias so that I would have been able to write imports such as import * from '@/utils'. The…

EuberDeveloper
- 874
- 1
- 14
- 38