Static GitHub Issues

[1725] Spread operator does not work in node_modules folder

prev: Question: vuetifyjs/nuxt with @nuxtjs/bootstrap-vue
next: Can't Change Port

Versions

  • node v6.11.2
  • nuxt v1.0.0-rc11

Intro

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.

Steps to reproduce

  • Init project with "nuxt-community/starter-template" template
  • Make component in node_modules folder
./node_modules/TestComponent/TestComponent.js

export default {
  methods: {
    someMethod () {
      const foo = {
        var1: 11,
        var2: 22
      }
      // let bar = {
      //   ...foo
      // }
      return {
        ...(foo || {})
      }
    }
  }
}
  • In index page import the component
./pages.index.vue

<script>
import TestComponent from '../node_modules/TestComponent/TestComponent.js'
...
</script>

What is actually happening ?

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

PS

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>