Search code examples
node.jsherokuvue.jsvue-clisnipcart

Vuejs and Nodejs deploying to heroku: $ npm run dev works but not $ node server.js


I made a website with Vue.js and included Snipcart API for a buy button. I've been trying to deploy it to heroku for 2 days now.

When I enter $ npm run dev it works fine and will display my web app. But for some reason if I do $ node server.js it shows the default Vue welcome page for its webpack ("Welcome to Your Vue App").

I've tried entering "start":"npm run dev" in my package.json but that just results in a forever loading web page. If I enter "start":"node server.js" It results in the same thing as the previous paragraph, it just shows the default Vue welcome page.

I found someone with basically the same issue (How to set up vue(2)-cli app to run with nodejs server) and even tried the same tutorial post but I don't know what that comment/answer is talking about. I am also unsure of how to deploy a static website with a Snipcart API (as a previous user mentioned to me in a previous post).

I am really at a loss as to what to do. Thanks for your time.

Edit: Here is the repo for my app: https://github.com/Taikon/MaroonRiver0


Solution

  • Exactly what I suspected in the comment: You are not building your assets.

    Run

    npm run build
    node server.js
    

    And it should work as expected.