Esbuild: Error using transform() API

Created on 6 May 2020  路  2Comments  路  Source: evanw/esbuild

Hi,

I run into an issue using transform() API.

When I run this example code :

(async () => {
  const ts = `
    export const value: number = 1;
  `;

  const esbuild = require("esbuild");
  const service = await esbuild.startService();

  try {
    const { js } = await service.transform(ts, { loader: "ts" });
    console.log(js);
  } catch (err) {
    console.error(err);
  }

  service.stop();
})();

I have the following error :

Error: Transform failed with 1 error
    at failureErrorWithLog (...\node_modules\esbuild\lib\main.js:35:17)
    at Object.transform (...\node_modules\esbuild\lib\main.js:250:38)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ...\es.js:10:20 {
  errors: [
    { text: 'Could not read from file: E:\\input.ts', location: null }
  ],
  warnings: []
}

If I create a ts file and call the CLI command npx esbuild, it works properly.

I'm on Windows 10, using Node v12.16.3.

Most helpful comment

Thanks for the report! I think I know why this happens. Will fix as soon as I can download a Windows VM for testing.

All 2 comments

Same here

Thanks for the report! I think I know why this happens. Will fix as soon as I can download a Windows VM for testing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamakulov picture iamakulov  路  4Comments

a7ul picture a7ul  路  3Comments

mohsen1 picture mohsen1  路  3Comments

lolychee picture lolychee  路  4Comments

tonyhb picture tonyhb  路  3Comments