I use in my project css framework vuetify and cant import VBtn component. For example I made a similar code to reproduce the same error.
./node_modules/TestComponent/TestComponent.js
export default {
methods: {
someMethod () {
const foo = {
var1: 11,
var2: 22
}
// let bar = {
// ...foo
// }
return {
...(foo || {})
}
}
}
}
./pages.index.vue
<script>
import TestComponent from '../node_modules/TestComponent/TestComponent.js'
...
</script>
When I start the assembly (npm run dev) the error gets out:
error in ./node_modules/TestComponent/TestComponent.js
Module parse failed: C:\Users\user\projects\nuxt-test\node_modules\TestComponent\TestComponent.js Unexpected token (12:8)
You may need an appropriate loader to handle this file type.
| // }
| return {
| ...(foo || {})
| }
| }
@ ./node_modules/babel-loader/lib?{"babelrc":false,"cacheDirectory":true,"presets":["C://Users//user//projects//nuxt-test//node_modules//babel-preset-vue-app//dist//index.common.js"]}!./node
_modules/vue-loader/lib/selector.js?type=script&index=0!./pages/index.vue 24:0-59
@ ./pages/index.vue
@ ./.nuxt/router.js
@ ./.nuxt/index.js
@ ./.nuxt/client.js
@ multi webpack-hot-middleware/client?name=client&reload=true&timeout=3000&path=/__webpack_hmr ./.nuxt/client.js
With other starter templates (webpack + ssr) there is no such error. But I already started the project on nuxt.
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1546">#c1546</a>)</em></sub></div>