sindresorhus / public-ip

Get your public IP address - very fast!
MIT License
1.02k stars 65 forks source link

Causes Typescript project build to fail #61

Closed mcfriend99 closed 2 years ago

mcfriend99 commented 2 years ago

When I import it into a Typescript project, the build fails with the following error.

const public_ip_1 = __importDefault(require("public-ip"));
                                    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/public-ip/index.js from /app/dist/index.js not supported.
Instead change the require of /app/node_modules/public-ip/index.js in /app/dist/index.js to a dynamic import() which is available in all CommonJS modules.
 at Object.<anonymous> (/app/dist/index.js:13:37) {
  code: 'ERR_REQUIRE_ESM'
 }

Node.js v17.6.0

Build command: tsc build && node dist/.

sindresorhus commented 2 years ago

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