Can't load the nuxt-i18n module in Nuxt with Typescript : SyntaxError: Unexpected character '@'

MarvinRudolph
0
MarvinRudolph
commented 2 months ago

Version

v6.0.2

Reproduction link

https://github.com/nuxt-community/nuxt-i18n

Steps to reproduce

  1. Create fresh Nuxt 2.9.1 project
  2. Make TypeScript works with the guide on https://typescript.nuxtjs.org/guide/setup.html
  3. Install and add nuxt-i18n module
  4. Create a class with @Component in a layout/page

What is expected ?

  • No SyntaxError: Unexpected character '@'
  • Compatible with parsePages: true;

What is actually happening?

Using @Component in a page/layout vue single file throws a SyntaxError: Unexpected character '@'.
=> works if parsePages is set to false

Additional comments?

New issue based on https://github.com/nuxt-community/nuxt-i18n/issues/128

bug
0
rchl
373
rchl
commented 2 months ago

parsePages: true is still an issue for typescript. Suggestion from https://github.com/nuxt-community/nuxt-i18n/issues/76#issuecomment-511153965 still stands.

0
tats-u
0
tats-u
commented 2 months ago

https://github.com/tats-u/nuxt-ts-vuetify-i18n-test
vomits a similar error.

ERROR  Unexpected character '@' (10:0)                                              19:57:01  

  at _class.pp$4.raise (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:2836:15)       
  at _class.pp$9.getTokenFromCode (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:4569:10)
  at _class.pp$9.readToken (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:4297:17)   
  at _class.pp$9.nextToken (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:4288:17)   
  at _class.pp$9.next (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:4245:10)        
  at _class.pp$3.parseLiteral (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:2299:10)  at _class.pp$3.parseExprAtom (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:2210:19)
  at _class.parseExprAtom (node_modules\nuxt-i18n\node_modules\acorn-dynamic-import\lib\index.js:75:117)
  at _class.pp$1.parseImport (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:1553:55) 
  at _class.pp$1.parseStatement (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:863:49)
  at _class.parseStatement (node_modules\nuxt-i18n\node_modules\acorn-dynamic-import\lib\index.js:63:118)
  at _class.pp$1.parseTopLevel (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:746:23)  at _class.parse (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:553:17)
  at Function.parse (node_modules\nuxt-i18n\node_modules\acorn\dist\acorn.js:576:37)
  at _19f‍.r.exports.extractComponentOptions (node_modules\nuxt-i18n\src\helpers\components.js:
20:61)
  at buildLocalizedRoutes (node_modules\nuxt-i18n\src\helpers\routes.js:29:21)
0
umervservices
0
umervservices
commented a month ago

I am not using TypeScript but having the error

ERROR EISDIR: illegal operation on a directory, read at Object.readSync (fs.js:493:3) at tryReadSync (fs.js:332:20) at readFileSync (fs.js:369:19) at exports.extractComponentOptions (node_modules\nuxt-i18n\src\helpers\components.js:12:45) at buildLocalizedRoutes (node_modules\nuxt-i18n\src\helpers\routes.js:34:21) at exports.makeRoutes (node_modules\nuxt-i18n\src\helpers\routes.js:141:46) at Object.extendRoutes (node_modules\nuxt-i18n\src\index.js:65:31) at Object.extendRoutes (node_modules\@nuxt\utils\dist\utils.js:1818:25) at Builder.resolveRoutes (node_modules\@nuxt\builder\dist\builder.js:5787:50)

0
rchl
373
rchl
commented 25 days ago

@umervservices then you shouldn't post it here. Feel free to create new issue with more info (you could start with your directory structure in your pages folder).

0
umervservices
0
umervservices
commented 22 days ago

I have figured out what actually happens, I am using extendRoutes in nuxt.config.js router unfortunately I have no way to access locales and current locale in nuxt.config.js if there is any way that would be great for my scenario

0
Informations
Bug ReportOpen
#c287 - Created 2 months ago