Typescrpit compiler not solving Path Mapping modules
up vote
1
down vote
favorite
I would like to use ts-node with .ts files that use path mapping like paths: { "@/*": ["src/*"] }
and import like import Sample from "@/sample"
instead of import Sample from "../../src/sample"
When when compiling tsc index.js
, I got this:
index.ts:1:18 - error TS2307: Cannot find module '@/sample.
What is the Correct configuration for ts-node
This is my tsconfig,json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"baseUrl": "./",
"paths": { "@/*": ["src/*"] },
"esModuleInterop": true
}
}
and my sample project: https://github.com/daniel-dia/ts-path-mapping
typescript tsc
add a comment |
up vote
1
down vote
favorite
I would like to use ts-node with .ts files that use path mapping like paths: { "@/*": ["src/*"] }
and import like import Sample from "@/sample"
instead of import Sample from "../../src/sample"
When when compiling tsc index.js
, I got this:
index.ts:1:18 - error TS2307: Cannot find module '@/sample.
What is the Correct configuration for ts-node
This is my tsconfig,json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"baseUrl": "./",
"paths": { "@/*": ["src/*"] },
"esModuleInterop": true
}
}
and my sample project: https://github.com/daniel-dia/ts-path-mapping
typescript tsc
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I would like to use ts-node with .ts files that use path mapping like paths: { "@/*": ["src/*"] }
and import like import Sample from "@/sample"
instead of import Sample from "../../src/sample"
When when compiling tsc index.js
, I got this:
index.ts:1:18 - error TS2307: Cannot find module '@/sample.
What is the Correct configuration for ts-node
This is my tsconfig,json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"baseUrl": "./",
"paths": { "@/*": ["src/*"] },
"esModuleInterop": true
}
}
and my sample project: https://github.com/daniel-dia/ts-path-mapping
typescript tsc
I would like to use ts-node with .ts files that use path mapping like paths: { "@/*": ["src/*"] }
and import like import Sample from "@/sample"
instead of import Sample from "../../src/sample"
When when compiling tsc index.js
, I got this:
index.ts:1:18 - error TS2307: Cannot find module '@/sample.
What is the Correct configuration for ts-node
This is my tsconfig,json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"baseUrl": "./",
"paths": { "@/*": ["src/*"] },
"esModuleInterop": true
}
}
and my sample project: https://github.com/daniel-dia/ts-path-mapping
typescript tsc
typescript tsc
edited Nov 22 at 14:57
asked Nov 22 at 11:51
Daniel Santos
2,18922356
2,18922356
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The problem is the invocation of the typescript compiler. If you are calling tsc
with a specific import file, it ignores a tsconfig.json
in the same directory:
When input files are specified on the command line, tsconfig.json
files are ignored.
Just change your build script to "build": "tsc"
and add "files": ["index.ts"]
to your tsconfig.json
.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The problem is the invocation of the typescript compiler. If you are calling tsc
with a specific import file, it ignores a tsconfig.json
in the same directory:
When input files are specified on the command line, tsconfig.json
files are ignored.
Just change your build script to "build": "tsc"
and add "files": ["index.ts"]
to your tsconfig.json
.
add a comment |
up vote
0
down vote
The problem is the invocation of the typescript compiler. If you are calling tsc
with a specific import file, it ignores a tsconfig.json
in the same directory:
When input files are specified on the command line, tsconfig.json
files are ignored.
Just change your build script to "build": "tsc"
and add "files": ["index.ts"]
to your tsconfig.json
.
add a comment |
up vote
0
down vote
up vote
0
down vote
The problem is the invocation of the typescript compiler. If you are calling tsc
with a specific import file, it ignores a tsconfig.json
in the same directory:
When input files are specified on the command line, tsconfig.json
files are ignored.
Just change your build script to "build": "tsc"
and add "files": ["index.ts"]
to your tsconfig.json
.
The problem is the invocation of the typescript compiler. If you are calling tsc
with a specific import file, it ignores a tsconfig.json
in the same directory:
When input files are specified on the command line, tsconfig.json
files are ignored.
Just change your build script to "build": "tsc"
and add "files": ["index.ts"]
to your tsconfig.json
.
answered Nov 22 at 14:54
Johannes Reuter
1,92479
1,92479
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53430420%2ftypescrpit-compiler-not-solving-path-mapping-modules%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown