I would import class in nodejs and use it in app.ts
var nano = require("nano"); import { EnvConfig } from './envConfig.service'; let config = new EnvConfig(); const dbCredentials: any = config.appEnv.getServiceCreds('dataservices'); export const nanodb = nano({ url: dbCredentials.url, }); export const nanodbCockpitLight = nanodb.use('data'); console.log(dbCredentials);
When I try to compile I get this error.
import { EnvConfig } from './envConfig.service'; ^ SyntaxError: Unexpected token {
I have created the tsconfig file :
{ "compilerOptions": { "module": "commonjs", "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "allowSyntheticDefaultImports": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es6", "sourceMap": true, "allowJs": true, "outDir": "./dist", //"baseUrl": "src" // Attention !! nécessite l'utilisation d'un loader de module node pour fonctionner sur node }, "include": ["src/**/*"], "exclude": ["node_modules", "**/*.spec.ts"] }
I get this warning
No inputs were found in config file 'c:/Users/EHHD05911.COMMUN/Documents/cockpitLight/DB mananger/tsconfig.json'. Specified 'include' paths were '["src//"]' and 'exclude' paths were '["node_modules","/.spec.ts"]'