sindresorhus/tempy

Must use import to load ES Module

x-ajay opened this issue · 3 comments

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/cluster/Code/cluster-pdf-api/node_modules/tempy/index.js
require() of ES modules is not supported.
require() of /home/cluster/Code/cluster-pdf-api/node_modules/tempy/index.js from /home/cluster/Code/cluster-pdf-api/dist/document/helper/compress.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/cluster/Code/cluster-pdf-api/node_modules/tempy/package.json.

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/cluster/Code/cluster-pdf-api/src/document/helper/compress.ts:5:1)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/cluster/Code/cluster-pdf-api/src/document/document.service.ts:18:1)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)

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

import tempy from 'tempy';

still having same issue

still having this issue