Skip to content

Commit

Permalink
Fix "Must use import to load ES Module"
Browse files Browse the repository at this point in the history
The actual error message was:

>  ERROR  Must use import to load ES Module: /Users/kana/working/hatokurandom/node_modules/lodash-es/lodash.js
> require() of ES modules is not supported.
> require() of /Users/kana/working/hatokurandom/node_modules/lodash-es/lodash.js from /Users/kana/working/hatokurandom/lib/utils.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 lodash.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/kana/working/hatokurandom/node_modules/lodash-es/package.json.

According to nuxt/nuxt#6718 (comment)

> Hi. Just as an update, we are working on next gen server for nuxt3
> (backported to nuxt2) which is using RollupJS to bundle
> server-middleware and natively supports mjs. In the meantime you can
> migrate from esm to jiti by setting this in nuxt.config:
  • Loading branch information
redhawkIT committed Dec 29, 2020
1 parent 66271a7 commit 3e8c5f4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default {
}
}
},
createRequire: 'jiti',
redirect: [
// For users who add the old offline version to home screen.
{ from: '^/offline$', to: '/', statusCode: 301 }
Expand Down

0 comments on commit 3e8c5f4

Please sign in to comment.