NuxtN
Nuxt2y ago
11 replies
David

Nuxt 2 and Directus SDK, not loading CommonJS module

Hello ! I'm trying to use the Directus SDK with the latest version of Nuxt 2. I am getting this error :
require() of ES Module /node_modules/@directus/sdk/dist/index.js from /node_modules/vue-server-renderer/build.dev.js not supported.
Instead change the require of index.js in /node_modules/vue-server-renderer/build.dev.js to a dynamic import() which is available in all CommonJS modules. 


The Directus SDK has an index.cjs file and I don't understand why vue-server-renderer tries to load the ES module instead of the CommonJS file.
I don't have
"type": "module"
in my
package.json
. I even tried to set
"type": "commonjs"
, but it still behaves the same.
Has anyone had that same kind of issue and would know about a trick to get it to work?
Was this page helpful?