Answer the question
In order to leave comments, you need to log in
Why are modules not being imported from node_modules in TS?
Good afternoon. A Node.js application is being written on TS without any assemblers. When building the project, all imports from node_modules are not connected and an error is generated, respectively. How can I make the import of libraries work correctly (without using bundlers a la Webpack, etc.)?
tsconfig.json:
{
"compileOnSave": true,
"compilerOptions": {
"target": "ESNext",
"module": "CommonJS",
"esModuleInterop": true,
"moduleResolution": "Node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": false,
"outDir": "../../packages/project",
"rootDir": "src"
},
"include": [
"src/**/*"
],
"exclude": ["node_modules"], // Комментирование этой строчки ни чего не даёт
"watchOptions": {
"watchFile": "useFsEvents",
"watchDirectory": "useFsEvents",
"fallbackPolling": "dynamicPriority",
"synchronousWatchDirectory": true,
"excludeDirectories": ["**/node_modules", "_build"], // Комментирование этой строчки ни чего не даёт
"excludeFiles": ["build/fileWhichChangesOften.ts"]
}
}
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "tsc",
"watch": "tsc --watch"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/node": "^17.0.12",
"@types/validator": "^13.7.1",
"typescript": "^4.5.5"
},
"dependencies": {
"dotenv": "^14.3.2",
"pg": "^8.7.1",
"pg-hstore": "^2.3.4",
"reflect-metadata": "^0.1.13",
"sequelize": "^6.14.1"
}
}
import { Sequelize, Dialect } from 'sequelize';
// код подключения к БД
Error: Cannot find module 'sequelize'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question