I cloned a project from GitHub and encountered some issues while trying to build it. I’ve already installed all the necessary dependencies using npm install, and I’m running MongoDB through the mongo shell. However, I’m getting the following errors when I run npm run build:
> rm -rf build && tsc --build && cp .env ./build/.env
MongoModels/index.ts:3:8 - error TS2303: Circular definition of import alias 'User'.
3 import User from './user';
~~~~
connectToDb.ts:1:22 - error TS2307: Cannot find module 'mongoose' or its corresponding type declarations.
1 import mongoose from 'mongoose';
~~~~~~~~~~
As you can see, we already are importing User in MongoModels/index.ts:
import User from './user';
import Category from './categories';
....
connectToDb.ts:
import mongoose from 'mongoose';
import { dbConfig } from './Config/index';
// const dbDriver = db_config.my_sql_db_config_server.dialect as Dialect
const connectToMongo = async() => {
let fetch_url = dbConfig.mongoDbConfig.uri
let options : any = {
useNewUrlParser: true,
useUnifiedTopology : true
}
mongoose.set("strictQuery", false);
mongoose.connect(fetch_url, options);
mongoose.connection.on("connected", (data) => {
console.log("connected to MongoDb");
});
mongoose.connection.on("error", (error) => {
console.log(error);
});
}
export {
connectToMongo
}
Am I missing any steps other than running npm install after cloning the project?