esm icon indicating copy to clipboard operation
esm copied to clipboard

Cache not updating when package is updated

Open tpluscode opened this issue 6 years ago • 1 comments

I am consuming packages which have a ESM-powered commonjs main module.

Problem is that when I update to a new version, the cache is not cleared and ESM stubbornly runs the cached code from the previously installed version.

Setting the no-cache environment variable or package.json options does not work. Only nuking the node_modules/esm/node_modules/.cache helps

Related to #805?

tpluscode avatar Apr 19 '20 14:04 tpluscode

I think I ran into a simmilar problem. I needed to clear some earlier required modules to be able to freshly riquire them at runtime. As soon as esm is initialized I will always get an cached module. I tried:

process.env.ESM_DISABLE_CACHE = true
require = require('esm')(module, { cache: false, cjs: { cache: false }, force: true })

If I test it without esm or @babel/register everythings works as expected and I will be able to freshly require modules.

dionysiusmarquis avatar Jun 16 '20 09:06 dionysiusmarquis