I'm trying to start a NextJS application on my Node server using Plesk but it is not working. I activated NodeJS for my Plesk environment, and I was able to run npm install and npm build, but now, when I try to start the application, Plesk only shows "Please wait" and stays like that with no change, I have been waiting for more than 2 hours now, but I don't get any results, no errors, nothing.
The only issue I can think of is that, according to what I could find, the Application startup file and the package.json file should be in the same directory, the root folder, but in my case this is not possible. I have my package.json in the root directory, but the startup file for NextJS, index.js, is inside the pages folder. I tested building and starting the app locally and everything works fine, I don't understand why it's not working with Plesk.
I was able to fix this after correcting the startup file, it should be "node_modules/.bin/next" and not "pages/index.js".
Also when you start your app, Plesk will tell you to wait. Just check the site and make sure it is running, if it is, you can close Plesk.
You might need to install Express in your Next.js
You may refer to this repo fmi # https://github.com/zeit/next.js/tree/canary/examples/custom-server-express
If you're referring to the package.json's command we'll have:
dev
build
start
In Plesk's Node Application extension.
Website & Domains > "Your Domain" > Enable Node.js
Simply set server.js as my Application Startup File.
Ensure that all dependencies is installed using "Npm Install" helper.
You must run build command before start command.
Screenshot:
Helpful NPM/Plesk reference:
Running scripts in Node.js Application
Adding .npmrc file in Node.js Application Root folder
Related
we uploaded our working laravel code on hostinger (shared servers).
Once uploaded we are having this error : Vite manifest not found at: /home/.../blog/public/build/manifest.json
Missing Vite Manifest File
We deleted the line #vite(['resources/css/app.css', 'resources/js/app.js']) from the code.
the application works this time but css and js of login doesn't work.
Do you have any idea of the issue please ?
Best regards,
Hello There hope it's not late.
In order to use vite in your Laravel project for the installed UI files in the Authentication Module, you have to migrate to your project and run the following commands.
npm install
npm run dev
But as long as you are in production run the below command.
npm run build
Then you'll be good to go.
shared hosting is sucks because we don't have ssh access and have very limited choice to do. But it is really cheap. so here is what I do to upload laravel 9 with vue.js on board with vite at hostinger shared hosting.
run npm run build on local
upload all files outside public_html
copy all the data at public directory to public_html. (copy not move)
that should resolve Vite manifest not found error
I was looking to deploy my Nodejs/TypeScript web application to my cpanel shared hosting. But, I am getting an error:
*
Cloudlinux NodeJS Selector demands to store node modules for
application in a separate folder (virtual environment) pointed by
symlink called "node_modules". That's why the application should not
contain folder/file with such name in application root*
I have created a nodejs application. The final nodejs/typescript folders-files were moved to the nodejs application directory. I also was able to install TypeScript as well as run yarn install after copying my virtual environment and running it from my local terminal by running ssh.
The issues is, from my nodejs application end, I cant 'run any script' or 'npm install' neither can I from my virtual terminal.
But yarn run real fine.
I'm also aware that another folder was created in my root hosting path called /nodevenv/ where another instance of my domain/sub-domain name lives.
Node executables folder/files.
What I dont know is, does it have anything to do with running npm script? Again, does it have anything to do with my application path?
Another weird thing I couldn't figure out is how to run the frontend and backend together. They both run fine on my local machine.
Do I create a subdomain for the server-side and the frontend from the main domain?
I want them to run together as they were running on the same port from my localhost: 8080.
How do I set them to run on the same port from my sharedhosting
What I did is, creating a proxy from the frontend package.json file like so:
"proxy": "example.com" and it was running fine from local machine.
Remove node_modules folder. and try to run your commands again.
Try Moving node_modules to public folder
It's occurring because the node_modules folder already exists, if you remove the folder, the command sent by "► Run NPM Install" button will execute successfully.
Currently I made a simple app with react, it works perfectly and I use react-scripts. I installed React by following the Facebook github page, and it written that "When you're ready to deploy to production, running npm run build will create an optimized build of your app in the build folder. ". After I press npm run build, a folder build created, but I do not know what to do with this folder. I tried some method like, move all folders except build and npm run, but it did not work. Anyone can explain me what is this folder "build" ? Thank you
npm run build builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
npm run build creates a build directory with a production build of your app. Set up your favourite HTTP server so that a visitor to your site is served index.html, and requests to static paths like /static/js/main..js are served with the contents of the /static/js/main..js file.
I'm deploying my node and express web application using nssm tool.
I've configured and installed my application as a service but when I navigate to
http://localhost:3000 the ./bin/wwww file is being downloaded instead of serving it.
My application is Node and Express. My startup file is app.js. I'm able to launch the application with the commands
npm start
or simply
nodemon
but cannot run the application using nssm. Can anyone help me what am I doing wrong?
I've switched to a different method.
qckwinsvc is simple and easy to use. I pointed the script path to my appdir\bin\www for this to work.
Bit of a n00b question:
I created project with vue-cli using webpack.
On my windows machine I run "npm un dev" and I get a frontend server with HMR and so on.
Now I want to deploy my app to a production machine - ubuntu on DigitalOcean.
What are the steps I must take? I'm not very familiar with the logic of how it's supposed to work. If my ubuntu machine has NODE_ENV set to production, it won't install any of the devDependancies and i'm not able to build anything. So I guess I'll have to change that? If yes then it doesn't make any sense since it's a production machine.
And do I have to create another node/express server to serve index.html? Won't it supposed to work out-of-the-box somehow?
Thanks :)
TL;DR Build on your local machine and everything you need will be outputted in the ./dist/ directory, just copy the contents over to the webroot on your production server and you're good to go.
The webpack template handles most of the stuff for you.
Step you need to take to release:
Run npm run build on your local machine
Copy the contents of the generated ./dist/ directory to your server webroot
That's it!
When you run npm run build, the pre-configured build script sets the node environment to production, and builds with only the stuff that should be in production, it also optimizes the code and removes debug capabilities. When it comes to dependencies webpack takes care of that and includes them in the generated javascript files located in the ./dist/js/, so you need not concern yourself with copying over the node_modules/ directory either.
It also copies over everything in your static directory and src/assets directory to the ./dist/ directory to be prepare for a release. And resolves all the references to the new path generated by webpack.
The production server should not be concerned with building the vue app, run the build command on your local machine to keep dev dependencies away from your production server. I recommend against installing webpack and other dev tools on your production server. It just pollutes the server with things not needed there.
Some development tools could potentially produce alot of issues on production servers. So best practice is to never install them.
You could optionally create your own release script that uses ftp or rsync, whatver you prefer to copy everything in the ./dist/ directory to the production server webroot. This could be a script in bash, if on windows, run it in git bash or something similar for example.
Hope that cleared things up, congrats on your first vue release!