0

Say I just have my folder structure like this

my_project \
    dist \
        index.js
        logger.js
    src \
        index.ts
        logger.ts
    tsconfig.json

and in index.ts I want to do something like this

import logger from 'src/logger';

how would I do it? I tried adding

...
basedir: ".",
paths: ["src"]
...

to tsconfig. This got it to compile and find the logger module at compile time, but then when I build and everything gets compiled to dist, index.js has require('src/logger'). Obviously Node has no idea what src is so this doesn't work. So how could I get this set up so that the built modules have the correct import paths?

1 Answer 1

2

I think what you're really looking for is relative paths, not absolute. Have you tried using

import logger from './logger';

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.