How do I import a node module transpiled from typescript into Nuxt?

775 views Asked by At

I have a generated typescript client from Nswag that I want to transpile and use in my Nuxt application.

I transpile my apiService.ts client to apiService.js with a basic tsconfig:

{
  "compilerOptions": {
    "module": "ES6",
    "target": "ES6"
  }
}

And import it to my project, I have tried both require and import.

import { PersonClient } from "./../services/api/apiService.js";
const apiService = require("./../services/api/apiService.js");

The application builds but when I try to load the page with my client I get:

exports is not defined
    at Module../services/api/apiService.js

I have tried googling around but I just don't know the right question to ask. How can I use my apiService.js?

Viual Studio Code gives me syntax highlighting when I import it to the project, so it should be possible?

0

There are 0 answers