Home > OS >  can't import the named export 'computed' from non ecmascript module pinia and Vue 2
can't import the named export 'computed' from non ecmascript module pinia and Vue 2

Time:04-16

After installing Pinia on my Vue 2 project, and imported it in the main.js file I got this error

Failed to compile.

./node_modules/pinia/dist/pinia.mjs 1147:44-52
Can't import the named export 'computed' from non EcmaScript module (only default export is available)

CodePudding user response:

This Vue configuration should do the trick

// vue.config.js
module.exports = {
  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.mjs$/,
          include: /node_modules/,
          type: "javascript/auto"
        }
      ] 
    }
  }
}

As mentioned in this Github issue.

  • Related