You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have imported the package as instructed as follows: const softDelete = require('mongoose-softdelete');
But whenever I'm running the project, I'm facing an error like below: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/subhasis/Work/mpac-dispenser/node_modules/mongoose-softdelete/src/mongoose-softdelete.js require() of ES modules is not supported. require() of /home/subhasis/Work/mpac-dispenser/node_modules/mongoose-softdelete/src/mongoose-softdelete.js from /home/subhasis/Work/mpac-dispenser/models/medicine.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 mongoose-softdelete.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/subhasis/Work/mpac-dispenser/node_modules/mongoose-softdelete/package.json.
Kindly fix this issue otherwise give a solution to overcome this. If I comment out the require line then it runs fine.
The text was updated successfully, but these errors were encountered:
The documentation needs to be updated for the JS example. You can go ahead and use import to use this package if you're using the latest version of NodeJS
I'm using the latest version of node. But I'm using require for all other imports. So if I use import statement only for this package then it gives me the following error: SyntaxError: Cannot use import statement outside a module @riyadhalnur kindly help regarding this
I have imported the package as instructed as follows:
const softDelete = require('mongoose-softdelete');
But whenever I'm running the project, I'm facing an error like below:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/subhasis/Work/mpac-dispenser/node_modules/mongoose-softdelete/src/mongoose-softdelete.js require() of ES modules is not supported. require() of /home/subhasis/Work/mpac-dispenser/node_modules/mongoose-softdelete/src/mongoose-softdelete.js from /home/subhasis/Work/mpac-dispenser/models/medicine.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 mongoose-softdelete.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/subhasis/Work/mpac-dispenser/node_modules/mongoose-softdelete/package.json.
Kindly fix this issue otherwise give a solution to overcome this. If I comment out the require line then it runs fine.
The text was updated successfully, but these errors were encountered: