Closed mmarszal closed 3 years ago
+1 Facing the same issue
+2 same here, i've downloaded the library in my project for using it
Same issue here. Reverting to 2.1.0
until fixed.
Thank you for the report and the documentation of the issue :) This is fixed in the new 3.1.0 release
I've been trying to work on node installations that support esm, and found that check-disk-space doesn't work out of the box on them. I've tested this on node 16.9.1. Using
require
works fine however.Whether or not if my package.json include
"type": "module"
, and then try to import check-disk-space viaimport checkDiskSpace from "check-disk-space"
, I get the following error in the console:However, if I make some minor changes to the module in such that I do the following:
"type": "module"
to check-disk-space's package.soncheck-disk-space.cjs.js
tocheck-disk-space.cjs
check-disk-space.es.js
tocheck-disk-space.mjs
"main": "./dist/check-disk-space.cjs.js"
to"main": "./dist/check-disk-space.cjs"
"import": "./dist/check-disk-space.es.js"
to"import": "./dist/check-disk-space.mjs"
"require": "./dist/check-disk-space.cjs.js"
to"require": "./dist/check-disk-space.cjs"
then I can use the
import
syntax without any problem in esm environments, andrequire
in commonjs environments. I am not sure if the above fix is the most optimal, but it allowed me to work in both environments without any problems.Testing code used was simply:
I've also tested this with typescript with
"target": "ESNext"
,"module": "ESNext"
, and"moduleResolution": "node"
in my tsconfig.json.