can't import the named export 'computed' from non ecmascript module pinia and Vue 2
Asked Answered
J

1

8

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)
Josephina answered 15/4, 2022 at 11:7 Comment(0)
P
10

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.

Photoactinic answered 15/4, 2022 at 11:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.