Не работают алиасы
ошибка:
$ ts-node src/main.ts
Error: Cannot find module 'utils/logger/logger'
Require stack:
- C:\Users\kiril\Desktop\ПРОГРАММИРОВАНИЕ\kirove-layout\src\main.ts
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1186:15)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\Users\kiril\Desktop\ПРОГРАММИРОВАНИЕ\kirove-layout\node_modules\@cspotcode\source-map-support\source-map-support.js:811:30)
at Function.Module._load (node:internal/modules/cjs/loader:1012:27)
at Module.require (node:internal/modules/cjs/loader:1271:19)
at require (node:internal/modules/helpers:123:16)
at Object. (C:\Users\kiril\Desktop\ПРОГРАММИРОВАНИЕ\kirove-layout\src\main.ts:1:1)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module.m._compile (C:\Users\kiril\Desktop\ПРОГРАММИРОВАНИЕ\kirove-layout\node_modules\ts-node\src\index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Object.require.extensions. [as .ts] (C:\Users\kiril\Desktop\ПРОГРАММИРОВАНИЕ\kirove-layout\node_modules\ts-node\src\index.ts:1621:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\kiril\\Desktop\\ПРОГРАММИРОВАНИЕ\\kirove-layout\\src\\main.ts'
]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
main.ts
import logger from 'utils/logger/logger'
import { getBackendEnvironment } from './backend/backend.environments'
import { getGlobalEnvironment } from './environments'
import { getFrontendEnvironment } from './frontend/frontend.environments'
import { globalStateMachine } from './state-machine'
import { EnumLayoutType } from './types'
async function bootstrap() {
await getGlobalEnvironment()
console.log(globalStateMachine.layoutType)
if (globalStateMachine.layoutType === EnumLayoutType.backend) {
await getBackendEnvironment()
} else if (globalStateMachine.layoutType === EnumLayoutType.frontend) {
await getFrontendEnvironment()
return
} else {
throw new Error('Layout type is not passed')
}
}
bootstrap()
.then(() =>
console.log(logger.success('The template has been successfully created!')),
)
.catch(error => {
console.error(logger.error(error))
process.exit(1)
})
.finally(() => console.log(logger.system('Process finished', '⏸️ ')))
tsconfig.json
{
"compilerOptions": {
"target": "ES2021",
"module": "commonjs",
"lib": ["ES2021"],
"baseUrl": "./",
"paths": {
"src/*": ["src/*"],
"utils/*": ["src/utils/*"]
},
"outDir": "dist",
"esModuleInterop": true
},
"include": ["src"]
}
package.json
{
"name": "kirove-layout",
"version": "2.0.0",
"main": "src/main.ts",
"private": false,
"license": "MIT",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only --exit-child src/main.ts",
"start": "ts-node src/main.ts",
"build": "tsc"
},
"devDependencies": {
"@types/inquirer": "^9.0.7",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"typescript": "^5.5.4"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"@types/node": "^22.5.1",
"chalk": "4.1.2",
"dotenv": "^16.4.5",
"inquirer": "^10.1.8",
"tsconfig-paths": "^4.2.0"
},
"engines": {
"node": "22.2.0",
"npm": "10.8.0",
"yarn": "1.22.19"
}
}