I have the following folder structure:
\---src | \---test | | \---login | | index.ts | \---utils | | utilsFuntion.ts i want to import the utilsFuntion from utils filder under src inside the login folder like this way: import {somefuntion} from 'utils/utilsFuntion';
instead of doing like this : import {somefuntion} from '../../../utils/utilsFuntion';
here is my tsconfig file:
{ "compilerOptions": { "target": "es6", "lib": ["dom", "dom.iterable", "esnext"], "strict": true, "module": "commonjs", "noEmit": true, "resolveJsonModule": true, "esModuleInterop": true, "baseUrl": "src", "paths": { "src/*": ["src/*"] } }, "include": ["src"] } after i add the src baseUrl and the paths i change the import like this: import {somefuntion} from 'utils/utilsFuntion'; i got error that say: Error: Cannot find module 'utils/helpFunction
any idea how to fix this?
i try:
./utils/utilsFuntion.ts ./utils/utilsFuntion utils/utilsFuntion.ts src/utils/utilsFuntion.ts src/utils/utilsFuntion
utils/helpFunction, but the actual file isutils/utilsFuntion.js. Double check spelling and i think you'll be fine =)allowJsin yourtsconfig.json