Nestjs failed to deploy on cpanel - node.js

I'm trying to deploy my backend application on cpanel and I'm getting an error like this
what should i do to solve this problem?
> test3#0.0.1 start /home/nandaken/inventory
> nest start
stderr:
npm WARN lifecycle The node binary used for scripts is /home/nandaken/nodevenv/inventory/12/bin/node but npm is using /opt/alt/alt-nodejs12/root/usr/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
sh: nest: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! test3#0.0.1 start: `nest start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the test3#0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/nandaken/.npm/_logs/2023-01-28T08_16_43_494Z-debug.log

Looks like cpanel is calling the startscript which is running nest start. More than likely, you only have production dependencies installed, so #nestjs/cli isn't installed because it is a devDependency. Either configure cpanel to call a different start script (like start:prod which should map to node dist/main) or change your start script to run the proper js file (like node dist/main). The other option would be to install #nestjs/cli as a production dependency, but I wouldn't suggest that

Related

NextJS not running on MacOS even after installing modules

So I've just created a NextJS project using create-next-app which went smoothly as expected. Then ran npm i just to be sure and saw all modules installed into node_modules
When I try to run npm run dev to start my nextjs app. it just says
sh: next: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! test#0.1.0 dev: `next dev`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the test#0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/john.v.n.pakson/.npm/_logs/2022-10-06T08_01_29_725Z-debug.log
It seems like npm is not detecting the node_modules i have installed.
Not sure if this is a mac or a zsh issue.
I'm using node version 12.22.12
Upgraded to 16.17.1 and still see the same error
> test#0.1.0 dev
> next dev
/var/folders/6y/xtlzp4z16dj0stxnqx8znj8w0000gn/T/dev-01c08137.sh: line 1: next: command not found
Okay I figured it out. It was caused by my file path on macos. My project was on a folder called Project/Test which might have confused zsh or mac. This in turn caused npm to not be able to find the correct scripts on my node_modules
When I moved my project to another folder I was already able to run npm run dev properly.
Cheers!

can not install nestjs app to hosting with cpanel

I have project with nestjs, and I am unable to install it to hosting,
got this error:
returncode: 1
stdout:
start-project#0.0.1 start:prod /home/enebbvmz/server/dist
node main.js
stderr:
/home/enebbvmz/nodevenv/server/dist/12/bin/node but npm is using /opt/alt/alt-nodejs12/root/usr/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.
[31m[Nest] 58145 - [39m06/10/2021, 7:13:28 PM [38;5;3m[PackageLoader] [39m[31mNo driver (HTTP) has been selected. In order to take advantage of the default driver, please, ensure to install the "#nestjs/platform-express" package ($ npm install #nestjs/platform-express).
[39m
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! start-project#0.0.1 start:prod: node main.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the start-project#0.0.1 start:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/enebbvmz/.npm/_logs/2021-06-10T15_13_28_703Z-debug.log
First, stop you app.
Your Application Root should be just server.
Aplication startup file should be dist/main.js.
Then you can click on Save Button, restart your app and click on Run Npm Install and will work.
I recommend you create a subdomain for backend, then you can use your main domain for your frontend app.

Error using Framework7 and service.js for hosting in the local host

when i clicked the npm run service. This error is what i am getting
I have used the same app in the following link:
https://github.com/valnub/f7-node-autocomplete-search-demo
framework7-react-app-template#3.0.0 service C:\Users\Tallam Tharun Sai\auto-complete
PORT=3001 nodemon service/service.js
'PORT' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! framework7-react-app-template#3.0.0 service: `PORT=3001 nodemon service/service.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the framework7-react-app-template#3.0.0 service script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Tallam Tharun Sai\AppData\Roaming\npm-cache\_logs\2020-07-10T18_16_54_175Z-debug.log
The answer for this is.
I have deleted the Package.json and Node modules from the project and again followed the steps to install the npm as (npm install).
Then I have the installed my npm app successfully.

Parcel command not found

In my project, I use Parcel to bundle everything. Now, I am at the point where I need to deploy my app.
I clone my git repo with my React app and I put in the Node server.
I tried every command possible to install parcel, but I always get the following error :
> pp-react#0.1.0 build /home/volodymk/react
> parcel build index.html
sh: parcel: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! pp-react#0.1.0 build: `parcel build index.html`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the pp-react#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/volodymk/.npm/_logs/2020-01-12T19_26_22_634Z-debug.log
How can I fix this ?
To run any installed node package (not just Parcel), use npx, the utility command shipped with npm. It executes packages that come with a runtime command in your node_modules/packagename/.bin directories.
As in npx parcel build index.html
More information available in the npx readme.

react scripts not found

I have a problem running npm start from my newly created project, the thing is the problem doesn't seem to occur outside of this folder (its a git repo, so it needs to be in here). If i create a new project in another folder and run npm start I have no issues at all.
So I recently started working in Ubuntu 18.04LTS, gone through all the setup of installing nodejs and npm.
Currently running versions:
node = 10.16.0
npm = 6.9.2
So I created my app by using npx create-react-app
When i run npm start inside this, it throws me an error:
sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! frontend#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the frontend#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
I tried create the app in another folder, testing if i can run npm start (yes) and the move this app to my repo, but then it fails again.
If i understand well what you wrote, "npm start" worked fine when you changed folders. If this is the case, you should know that Node has issues reading the path when some particular characters (like "&") or spaces are in the name of a folder.
Try to change the folder's name.

Resources