Nuxt.js: Nuxt cannot initialize

Created on 29 Jan 2018  Â·  26Comments  Â·  Source: nuxt/nuxt.js

Node version: v6.9.5
NPM version: 3.10.10
Nuxt version: latest

â–¶ nuxt
/Users/hsacramento/.nvm/versions/node/v6.9.5/lib/node_modules/nuxt/lib/core/module.js:14
  async ready() {
        ^^^^^
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/hsacramento/.nvm/versions/node/v6.9.5/lib/node_modules/nuxt/lib/core/index.js:2:16)
    at Module._compile (module.js:570:32)

This question is available on Nuxt.js community (#c2358)

Most helpful comment

Nuxt.js 1.x requires node >=8 and npm >=5

cf. package.json https://github.com/nuxt/nuxt.js/blob/dev/package.json#L56

All 26 comments

Nuxt.js 1.x requires node >=8 and npm >=5

cf. package.json https://github.com/nuxt/nuxt.js/blob/dev/package.json#L56

My https socket server is not working with a node version > 6.11 so what should I do?

@Duzbee I guess this is the issue of HTTPS socket server then, not Nuxt.js. Or you could roll back to 0.x, which is most probably less favourable :confused:

Update node to version 8 helped. Thanks for the help.

firebase functions is node 6-only

I am also getting this issue while trying to run firebase deploy on my nuxt project. Firebase functions are only compatible with node 6 while nuxt is compatible with node 8+, so downgrading to node 6 is not an option for me.

Anyone else having this problem?

facing the same issue, is there a workaround??

I solve this problem by using last version nuxt in firebase function deploy

here package.json

{
"name": "functions",
"description": "Nuxt-SSR",
"dependencies": {
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.26.0",
"clone": "^2.1.1",
"debug": "^3.1.0",
"es6-promise": "^4.2.4",
"express": "^4.16.3",
"firebase-admin": "^5.11.0",
"firebase-functions": "^0.9.1",
"lodash": "^4.17.5",
"nuxt": "1.0.0-rc11",
"vue": "~2.5.16",
"vue-meta": "^1.5.0",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"private": true
}

Hi, I am also getting this issue.

/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run dev --scripts-prepend-node-path=auto

> [email protected] dev /Users/marine/Documents/HETIC/OYSTR/dev/oystrapp
> nuxt

/Users/marine/Documents/HETIC/OYSTR/dev/oystrapp/node_modules/nuxt/lib/core/module.js:14
  async ready() {
        ^^^^^

SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/marine/Documents/HETIC/OYSTR/dev/oystrapp/node_modules/nuxt/lib/core/index.js:2:16)
node version : v8.0.0
npm version : 5.0.0
nuxt version : 1.4.0

I'm getting this issue as well, but only when I attempt to build in a non-public dir. Everything works great when I build at ~/ however it fails at /var/task.

@MarineLB try to upgrade your node.js version to the latest 8 LTS (currently v8.11)

I have the same issue with firebase deploy on my nuxt project.
Firebase functions are only compatible with node 6
Nuxt is compatible with node 8+...

What a dilemma...... What should I choose? My project uses both Nuxt and Firebase, so I can't choose one of two...

@mesqueeb
Do you have any problem using Node 8 with firebase ?

Per firebase's engine and ci jobs(current stable node version is 10.1.0), I think firebase supports node 8.

solve it by using node v8.11.2

@clarkdo Unfortunately Google Cloud Functions, which Firebase Functions run upon only supports Node 6.11.5. It fails to run the async/await code used in the Nuxt module.

Is there maybe a way to compile Nuxt itself to es6 code using Babel or something? This is really kinda my last resort here.

@meta7x
In current dev branch, we have a nuxt-legacy which is an alternative nuxt entry and transpiled from Babel, maybe we’ll consider to add cli support on it for supporting the legacy node versions.
/cc @Atinux @pi0

The latest build of nuxt-edge supports Node 6.x again by automatically falling back to the legacy build.

image

PS: Don't forget to add babel-polyfill dependency to your project if you need legacy build.

Make sure to check your Node and Nuxt version. For Nuxt 1.4.0 you need at least Node 8.0.0.
Also, did you use the starter template?

@pi0 I deployed a project using nuxt-edge and the firebase function log telling me there is a problem with babel-polyfill. This is the error

2018-06-14T12:43:26.094Z D jefrydcossr: Code in file index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: Error: only one instance of babel-polyfill is allowed
    at Object.<anonymous> (/user_code/node_modules/nuxt-edge/node_modules/babel-polyfill/lib/index.js:10:9)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/user_code/node_modules/nuxt-edge/dist/nuxt-legacy.js:50:1)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
2018-06-14T12:43:26.206Z E jefrydcossr: undefined
2018-06-14T12:51:04.440Z N jefrydcossr: undefined
2018-06-14T12:53:28.052Z N jefrydcossr: undefined

But when I serve locally, it worked.

@meta7x node 8 worked, thanks for the help! Was using the starter template.

This page: https://nuxtjs.org/guide/installation really needs to specify that nuxt only runs on node 8 though, as not running the right version of node is breaking. Tha

As a side note, it's unfortunate how much of a pain it is to switch or upgrade node on the Mac. (and how nvm is its own little nightmare to install and use)

@janzheng I'm using n on a Mac and the version switching works like a breeze. Just $npm install -g n and then eg. n 6.11.5 should install and activate node 6.11.5 or whatever version you need.

Hmm just purely using npm doesn't work for me (throws a ton of errors), so had to go down the nvm route, but nvm was throwing other errors, so I had to go fix those. But all is well and nuxt is up and running (and it's awesome, I think it's easier to use than Middleman, which I've been running for a while)

Error: Could not compile template /home/dipesh/nuxt/nuxt1/node_modul es/nuxt/lib/app/App.js: Cannot resolve "~assests/app.styl" from "/ho me/dipesh/nuxt/nuxt1/assests/app.styl"

how to solve this please...

I was on node v10.8.0 when I got this, switched to v8.6.0 (using nvm) and did a redeploy and it worked.

(FYI Firebase Cloud Functions now support node 8)

Hey, for those having the issue on Firebase, I found the solution.

Firebase Cloud Functions now supports node 8:
https://firebase.googleblog.com/2018/08/cloud-functions-for-firebase-config-node-8-timeout-memory-region.html

What I did:

  1. Add "engines": {"node": "8"}, in functions/package.json
  2. Add babel-polyfill in nuxt.config.js's vendor.
+++ b/src/nuxt.config.js
   buildDir: '../functions/nuxt',
   build: {
     publicPath: '/',
-    vendor: ['isomorphic-fetch'],
+    vendor: ['isomorphic-fetch', 'babel-polyfill'],
     extractCSS: true,
     babel: {

And it worked!

This is my sample project. Hope it's helpful: https://github.com/wataruoguchi/nuxtjs-firebase-example

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

lazycrazy picture lazycrazy  Â·  3Comments

bimohxh picture bimohxh  Â·  3Comments

gary149 picture gary149  Â·  3Comments

msudgh picture msudgh  Â·  3Comments

danieloprado picture danieloprado  Â·  3Comments