3

when I try to import {Model, Mongoose} from 'mongoose', it actually looks for ./src/mongoose.ts that's the file generated by feathers by default. this problem only arises when I use the below property in tsconfig.ts.

"baseUrl": "./src"

I have to use this property in my project and have to avoid that problem too?

when I try to set this property for absolute paths in tsconfig.json. I get an error from file /src/models/users.model.ts.

line generating the error:

import { Model, Mongoose } from 'mongoose';

error generated:-

error TS2614: Module '"mongoose"' has no exported member 'Mongoose'. Did you mean to use 'import Mongoose from "mongoose"' instead?

Sibtain Wani
  • 89
  • 1
  • 9
  • tsconfig file{ "compilerOptions": { "target": "es2018", "module": "commonjs", "outDir": "./lib", "rootDir": "./src", "strict": true, "esModuleInterop": true, // "moduleResolution": "node", // "baseUrl": "./src", // "typeRoots" : ["./node_modules/@types", "./src/@types"] }, "exclude": ["test"] // "include": ["src"] } – Sibtain Wani Sep 08 '21 at 08:12

1 Answers1

1

try this

"baseUrl": "src" and "include": ["src/*.ts"]
Bipin Shrestha
  • 404
  • 4
  • 14
  • when I try to set "baseUrl": "./src", its trying to resolve node-modules folder in ./src – Sibtain Wani Sep 10 '21 at 09:09
  • what about just "src"? – Bipin Shrestha Sep 13 '21 at 03:43
  • { "compilerOptions": { "target": "es2018", "module": "commonjs", "outDir": "./lib", "rootDir": "./src", "strict": true, "esModuleInterop": true, "baseUrl": "src", "paths": { "@services/*": ["services/*"], "@models/*": ["models/*"], "*": ["../*"] } }, "exclude": [ "test" ], "include": ["src/**/*"] } – Sibtain Wani Sep 13 '21 at 06:34