Search code examples
phpnode.jslaravelnpmhosting

How to run 'npm run dev' on siteGround server


I have been developing a laravel website, and I am now trying to host it. SiteGround was recommended to me by a friend, so I bought a plan from them from a year and have uploaded and configured my files so that it connects to the database correctly etc. However, I am now getting the basic laravel 'vite manifest not found' error, where it tells me to run npm run dev, which i would normally do from VS Codes terminal.

However, I am not sure how I am meant to run it from SiteGround, or if this error should even be a thing considering I'm looking for the website to be hosted. I've seen stuff relating to SSH key's, but after looking into it and seeing the need for various applications to connect to such stuff, Im checking to see if there are any simpler options or fixes.

Im new to hosting laravel applications, and could really use some help on how to get this error resolved. If you need more info, please let me know.


Solution

  • Delete the node_modules directory, and run npm install, then npm run build or npm run dev.

    When in production you do not need to run npm run dev at all. If you are using a standard PHP with Blade and Livewire, it will work out of the box just fine. As long as the .env file is configured correctly, you should be good. If you need further details with any other issues, please update your question with specifics.

    One thing to keep in mind while in dev mode, if you are hosting the site, and run npm run dev, all resources loaded with @vite() will try and load a localhost version (https://[::1]/script).

    To develop remotely, I will run dev locally, but also run php artisan down --with-secret so only I can access the site, and the resources it is loading are local to my PC.

    A better option though honestly is to develop locally, upload, tweak the .env variables, and go.

    You can get into VC with GIT, and use a GitHub and Packagist account and run composer require to install your package.