1
votes

I have my app created with nuxt js. I just want to push my app on Netlify.

So firstly i configure my deploy settings :

Repository on git

Base directory : Not set

Build command npm run build && npm run start

Publish directory .nuxt/dist

My app is build correctly but npm run start just launch on localhost:3000

I decided to modify config Host, I don't know if it's the best solution ?

{
  "name": "app-nuxt",
  "version": "1.0.0",
  "description": "My remarkable Nuxt.js project",
  "author": "wyllisMonteiro",
  "private": true,
  "config": {
    "nuxt": {
      "host": "https://mywebsite.com"
    }
  },
  "scripts": {
    "dev": "HOST=localhost PORT=3000 nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "test": "jest"
  },
  "dependencies": {
    "@nuxtjs/axios": "^5.3.6",
    "cookieparser": "^0.1.0",
    "cross-env": "^5.2.0",
    "js-cookie": "^2.2.0",
    "nuxt": "^2.4.0",
    "vee-validate": "^2.2.0",
    "vuelidate": "^0.7.4",
    "vuetify": "^1.5.5",
    "vuetify-loader": "^1.2.1"
  },
  "devDependencies": {
    "@vue/test-utils": "^1.0.0-beta.27",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "^24.1.0",
    "coffee-loader": "^0.9.0",
    "coffeescript": "^2.4.0",
    "jest": "^24.1.0",
    "node-sass": "^4.11.0",
    "nodemon": "^1.18.9",
    "pug": "^2.0.3",
    "pug-plain-loader": "^1.0.0",
    "sass-loader": "^7.1.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.2",
    "vue-jest": "^3.0.3"
  }
}

I want to launch in localhost:3000 by executing npm run dev AND https://mywebsite.com by executing npm run start

Can you tell me if there is some modifications in my package.json or in my deploy settings on Netlify

2
My understanding is that you can only host a statically generated site on Netlify at this stage. As you are trying npm run start it would seem you have a Universal app. See docs. If you want a free hosting option, you might want to consider Heroku instead.Andrew1325

2 Answers

1
votes

For anyone that stumbles across this in the future, the problem you're experiencing is due to a misunderstanding with what services Netlify offers.

Specifically, they are primarily a static site host, which means they will host your built files, and serve them for you. They will not run your server, which means nuxt start will not run.

Instead, you should be using nuxt generate to generate the static files of your app, and telling Netlify where the output folder is.

For example, the "build settings" on Netlify:

Repository         github.com/example/example
Base directory     Not set
Build command      npm run generate
Publish directory  dist

This will properly deploy a Nuxt app, assuming you haven't changed the default build folder. For clarification, the .nuxt folder contains both client and server files, and can only be used when running your own Nuxt server on an instance of some kind.

0
votes

As it looks you need to tweak your deployment command. Go to Netlify and try changing it to npm install; npm run build. This should resolve the problem.