Nuxt.js: Error using coffee-loader as outlined in the docs

Created on 19 Jun 2017  Â·  5Comments  Â·  Source: nuxt/nuxt.js

I'm getting a parse error when attempting to use coffee-loader as outlined here:

https://nuxtjs.org/faq/pre-processors/#how-to-use-pre-processors-

I'm using a recent-ish node+npm, is there something else I need to do (a config file, maybe...?) in order to get coffeescript working inside .vue files?

$ nvm use 7
Now using node v7.10.0 (npm v4.2.0)

$ vue init nuxt/starter coffee-test
$ cd coffee-test
$ npm install 
$ npm install --save-dev [email protected] pug-loader coffee-script coffee-loader node-sass sass-loader
$ vim pages/index.vue    # modify `<script>`, see content below in error trace
$ npm run build

> [email protected] build /private/tmp/coffee-test
> nuxt build

[nuxt] Building...
  nuxt:build App root: /private/tmp/coffee-test +0ms
  nuxt:build Generating /private/tmp/coffee-test/.nuxt files... +1ms
  nuxt:build Generating files... +6ms
  nuxt:build Generating routes... +5ms
  nuxt:build Building files... +15ms
Build completed in 7.526s

[nuxt:build:client]
 Hash: cb5f2fae7007639d95af
Version: webpack 2.6.1
Time: 7531ms
                                Asset       Size  Chunks             Chunk Names
0.nuxt.bundle.18326821bb0f9ece41a2.js    8.01 kB       0  [emitted]  pages/index
1.nuxt.bundle.a137ddf7cda7d661e52b.js    2.78 kB       1  [emitted]  layouts/default
vendor.bundle.262d580d57297eb711d1.js     135 kB       2  [emitted]  vendor
  nuxt.bundle.e795fc9f10e9fa381fea.js    23.9 kB       3  [emitted]  app
     manifest.cb5f2fae7007639d95af.js    1.51 kB       4  [emitted]  manifest
                           index.html  132 bytes          [emitted]
                 client-manifest.json    5.57 kB          [emitted]

ERROR in ./pages/index.vue

/private/tmp/coffee-test/pages/index.vue
  23:13  error  Parsing error: Unexpected token, expected ;

  3 |
  4 | module.exports =
> 5 |   components: { Logo }
    |             ^
  6 | /* HTML */
  7 |

✖ 1 problem (1 error, 0 warnings)

 @ ./.nuxt/router.js 9:9-97
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
Error: Webpack build exited with errors
    at /private/tmp/coffee-test/node_modules/nuxt/dist/nuxt.js:1170:46

Just to confirm the exact contents of the <script> block:

$ grep -A5 '<script' pages/index.vue
<script lang="coffee">
import Logo from '~components/Logo.vue'

module.exports =
  components: { Logo }
</script>

This question is available on Nuxt.js community (#c790)
help-wanted

Most helpful comment

Looks like it's eslint running on .vue files and doesn't consider lang="coffee". after disabling eslint it works.

All 5 comments

running in the same issue. have you been able to resolve this?

i just ended up falling back on plain vue init webpack.

Looks like it's eslint running on .vue files and doesn't consider lang="coffee". after disabling eslint it works.

after disabling eslint it works.

_Happily_.

Thanks @buhrmi

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

surmon-china picture surmon-china  Â·  3Comments

pehbehbeh picture pehbehbeh  Â·  3Comments

o-alexandrov picture o-alexandrov  Â·  3Comments

vadimsg picture vadimsg  Â·  3Comments

bimohxh picture bimohxh  Â·  3Comments