Railway app not able to install when deploying NestJS application - node.js

I am trying to deploy a NestJS application on Railway.
I am using NPM as my package manager.
I have explicitly defined a run command and a build command in the project settings.
Whenever I try to deploy the project, I get the following error.
#13 3.042 npm WARN config production Use `--omit=dev` instead.
#13 3.134 npm ERR! Missing script: "install"
#13 3.134 npm ERR!
#13 3.134 npm ERR! Did you mean this?
#13 3.134 npm ERR! npm uninstall # Remove a package
#13 3.135 npm ERR!
#13 3.135 npm ERR! To see a list of scripts, run:
#13 3.135 npm ERR! npm run
#13 3.137
#13 3.137 npm ERR! A complete log of this run can be found in:
#13 3.137 npm ERR! /root/.npm/_logs/2023-01-14T18_01_46_797Z-debug-0.log
Has anybody experienced this before, where it can't recognize the install command?
I have tried with and without the custom build command, but every time it fails when running the npm run install step in the docker container.

I think the command that should run to install is npm install instead of npm run install. Have you tried checking the package.json file and tried adding "install": "npm install" inside scripts

Related

I cannot install packages nodejs packages on docker?

I am new on docker. I first build dockerfile after install get only error. This is Dockerfile:
FROM node
WORKDIR '/app'
COPY package*.json .
RUN npm i -g npm#latest
RUN npm install
COPY . .
CMD ["npm", "run", "start"]
When run docker build . command I get this error:
=> ERROR [5/6] RUN npm install 150.9s
------
> [5/6] RUN npm install:
#9 43.89 npm WARN deprecated w3c-hr-time#1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
#9 73.65 npm WARN deprecated svgo#1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
#9 88.65 npm WARN deprecated stable#0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
#9 149.2 npm ERR! code ERR_SOCKET_TIMEOUT
#9 149.2 npm ERR! network Socket timeout
#9 149.2 npm ERR! network This is a problem related to network connectivity.
#9 149.2 npm ERR! network In most cases you are behind a proxy or have bad network settings.
#9 149.2 npm ERR! network
#9 149.2 npm ERR! network If you are behind a proxy, please make sure that the
#9 149.2 npm ERR! network 'proxy' config is set properly. See: 'npm help config'
#9 149.3
#9 149.3 npm ERR! A complete log of this run can be found in:
#9 149.3 npm ERR! /root/.npm/_logs/2023-02-17T12_09_49_294Z-debug-0.log
------
executor failed running [/bin/sh -c npm install]: exit code: 1
This is a Dockerfile that works for me
FROM node:18-bullseye
WORKDIR /node-app
COPY package-lock.json package.json ./
RUN npm ci
COPY . .
Your issue is to remove the quote from the WORKDIR '/app' when copying the package-lock.json and package.json they should be COPYed to ./
The 3rd line RUN npm ci, is used to install packages that are in your package-lock.json file so you keep the same libraries as a BEST PRACTICE, npm install it may fetch some updates to some packages that you have, so as I mentioned, it's a best practice to use npm ci instead of npm install

Installing dependencies with npm-peer-dependencies

I am trying to install the required node_modules for a small project running Angular 11 using npm install
My goal is get the project to work locally after downloading it from GitHub. I have already installed the latest version of the Angular CLI.
After running the install command I tried npm start.
I was expecting that after running the install and start command to be able to run the project locally.
However the actual result I get after running the install command is the following list of errors:
> ng serve
An unhandled exception occurred: Cannot find module '#angular/compiler'
Require stack:
\node_modules\#angular\compiler-cli\index.js
\node_modules\#ngtools\webpack\src\angular_compiler_plugin.js
\node_modules\#ngtools\webpack\src\index.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\typescript.js
\node_modules\#angular-devkit\build-angular\src\webpack\configs\index.js
\node_modules\#angular-devkit\build-angular\src\browser\index.js
\node_modules\#angular-devkit\build-angular\src\dev-server\index.js
\node_modules\#angular-devkit\architect\node\node-modules-architect-host.js
\node_modules\#angular-devkit\architect\node\index.js
\node_modules\#angular\cli\models\architect-command.js
\node_modules\#angular\cli\commands\serve-impl.js
\node_modules\#angular-devkit\schematics\tools\export-ref.js
\node_modules\#angular-devkit\schematics\tools\index.js
\node_modules\#angular\cli\utilities\json-schema.js
\node_modules\#angular\cli\models\command-runner.js
\node_modules\#angular\cli\lib\cli\index.js
\node_modules\#angular\cli\lib\init.js
\node_modules\#angular\cli\bin\ng
See "angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file C:\WINDOWS\system32\cmd.exe
npm ERR! errno ENOENT
npm ERR! `ng serve`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the #0.0.16 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:
The problem is that this Angular project also has peer dependencies. I installed npm-install-peers package but it seems that simply running npm install afterwards will not install the required peer dependencies.
What should I do next to get this Angular project installed locally ?
The issue you are facing is likely because angular cli or npm-peer-dependencies are not installed globally on your machine.
The steps that you should take are to make sure of them are globally installed.
To install packages globally you need run npm install -g <package_name>
npm docs link
In your case for angular cli you should run
npm i -g #angular/cli#11.2.15 and npm install -g npm-peer-dependencies.
Then run npm start.

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.

React native 'unable to find expo in the project

I am working for my study on a React Native project, with group members. My group member who made the project has no problems running the project. I have expo installed globally, but can not run the program:
Unable to find expo in this project - have you run yarn / npm install yet?
├─ action C:\Users\thoma\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:34:11
├─ C:\Users\thoma\AppData\Roaming\npm\node_modules\expo-cli\src\commands\start.ts:135:22
└─ expo start C:\Users\thoma\AppData\Roaming\npm\node_modules\expo-cli\src\exp.ts:350:7
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\thoma\AppData\Roaming\npm-cache\_logs\2021-06-07T11_27_47_082Z-debug.log
What can I do to solve this?
At the root of your project, Run command
yarn
So basically your partner would have added few dependencies and committed his code. Now after fetching you need to have those dependencies in your project which is why you would have to run above command.
You can also use npm install, depending upon your system configurations.
This is because you are not in your project folder.
You need to run this command:
expo start
inside the project folder.

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.

Resources