解决模块存在时的“无法找到模块”

时间:2019-07-25 17:31:22

标签: node.js

我正在尝试从文件中提取数据并运行它

我有2个文件-dbConnectionService文件

 // fileName: dbConnection.service.ts. This should give me all db 
 // connection details from my json based on id

 class DbConnectionService {
    public dbDetails = this.pluck(argv.dbID);

    private pluck(dbId: string): IDB {

         return DB_CONNECTION_DATA.find(({id}) => {
          return id === dbId;
    });
  }

 export default new DbConnectionService();

,此类是从另一个这样的文件中调用的

  // FileName test.sql.ts
  var DbConnectionService= 
        require('../services/dbConnection.service');

  //import DbConnectionService from "../services/environment.service";

 const dbDetails = DbConnectionService.dbDetails
 console.log (dbDetails)

运行node xxx/xx/buyerData.sql.ts时出现此错误

  

错误:找不到模块'../ services / dbConnection.service'

,但可以确定文件存在。所以不确定在这里的抽象中我缺少什么

0 个答案:

没有答案