rubystarashe / nuxt-vuex-localstorage

MIT License
161 stars 18 forks source link

Got error "Uncaught SyntaxError: Unexpected token ..." #3

Closed attract closed 3 years ago

attract commented 5 years ago

Version: "nuxt": "^2.0.0" "nuxt-vuex-localstorage": "^1.2.6"

 const bindLocalStorage = name => {
    const localPersist = JSON.parse(crypto.decrypt(storageFunction.local.get(name)))
    let data = { ...store.state }
    const expireChecked = nuxt_vuex_localstorage_plugins_bindStorage_expire__WEBPACK_IMPORTED_MODULE_1__["default"].check(localPersist)
    if (store.state[name] && expireChecked[versionPropName] === store.state[name][versionPropName])
      data[name] = { ...data[name], ...expireChecked, status: true }
    store.replaceState(data)

    localStoreNames.forEach((name, i) => {
      watchHandlers_local[i] = watcher_local(name, i)
    })
  }

Error in line let data = { ...store.state }

Can you help?

Thanks

attract commented 5 years ago

I tried to update the version nuxt to 2.4.3 (as in the example - https://github.com/rubystarashe/nuxt-vuex-localstorage-example), the error remained..

rubystarashe commented 5 years ago

Check your nuxt.config.js. Perhaps that syntax error can occur if a module is loaded from the wrong position(such as before nuxt compile)

https://github.com/rubystarashe/nuxt-vuex-localstorage-example Is it not working? I tested this repo a little while ago, and it works.

attract commented 5 years ago

I did not check your example, only compare package version with my package.json

Trying change position in package.json, set the last, same result.

stasoft91 commented 5 years ago

IE11, I guess it is some babel-kind error, no object spread in older browsers, but i can find object spread in vendors.app.js

Untaek commented 5 years ago

Hi. I solved this issue. How it works

// Add that code to nuxt.config.js
build: {
  // ...
  transpile: [
    /(.+)(nuxt-vuex-localstorage\/)(.+)(\.js)$/
  ],
  // ...
}

This build option make to transpile specific library. And when you try to run any build script, incompatible codes will be changed.

akeyboardlife commented 5 years ago

Hi. I solved this issue. How it works

// Add that code to nuxt.config.js
build: {
  // ...
  transpile: [
    /(.+)(nuxt-vuex-localstorage\/)(.+)(\.js)$/
  ],
  // ...
}

This build option make to transpile specific library. And when you try to run any build script, incompatible codes will be changed.

It's wierd why

build: {
  // ...
  transpile: [
    "nuxt-vuex-localstorage"
  ],
  // ...
}

won't work.

As stated here, it can be a package name.

rubystarashe commented 3 years ago

maybe it was problem specific version nuxt