sindresorhus / tempy

Get a random temporary file or directory path
MIT License
423 stars 26 forks source link

Top level await error #49

Closed daryl-sf closed 4 months ago

daryl-sf commented 1 year ago

Hi,

I'm getting an error Top-level await is not available in the configured target environment ("node14") when upgrading from 3.0.0 to 3.1.0.

✘ [ERROR] Top-level await is not available in the configured target environment ("node14")

    node_modules/temp-dir/index.js:4:27:
      4 │ const temporaryDirectory = await fs.realpath(os.tmpdir());
        ╵                            ~~~~~

I'm guessing tempy is asking for engine >=14.16 but top-level await is available from 14.8 onwards.

crystalfp commented 8 months ago

Similar error for me in an electronJS application:

Module format "cjs" does not support top-level await. Use the "es" or "system" output formats rather.
file: D:/Projects/STMng/node_modules/temp-dir/index.js

temp-dir is a dependency of tempy

sindresorhus commented 4 months ago

This is a problem with your bundler config, not this package.

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c