Error: Cannot find module '/app/backend/index.js'
batoqqqa
FREEOP

7 months ago

Hello, I'm trying to host express js app, but I got an Error:
Node.js v18.20.5

node:internal/modules/cjs/loader:1143

throw err;

^

Error: Cannot find module '/app/backend/index.js'

at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)

at Module._load (node:internal/modules/cjs/loader:981:27)

at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)

at node:internal/main/run_main_module:28:49 {

code: 'MODULE_NOT_FOUND',

requireStack: []

}

Solved$10 Bounty

9 Replies

marktawa
HOBBY

7 months ago

Hi
Please show me your project's folder structure (just the top-level files and folders) and your package.json contents here


marktawa

HiPlease show me your project's folder structure (just the top-level files and folders) and your package.json contents here

batoqqqa
FREEOP

7 months ago

Hello, here it is. I guess i need to toggle the visibility of the project?


marktawa
HOBBY

7 months ago

Did you configure your Railway project's root folder to be backend?
By default, Railway runs from the root of the repo, so if your Express app is inside the backend/ folder, you'll need to either set the root directory in Railway to backend, or move the app files to the project root.


marktawa

Did you configure your Railway project's root folder to be backend?By default, Railway runs from the root of the repo, so if your Express app is inside the backend/ folder, you'll need to either set the root directory in Railway to backend, or move the app files to the project root.

batoqqqa
FREEOP

7 months ago

I am not sure but it seems like yes I configured the project

Attachments


marktawa
HOBBY

7 months ago

Show me your build logs. Right from the start


marktawa

Show me your build logs. Right from the start

batoqqqa
FREEOP

7 months ago

Here
[Region: asia-southeast1]

May 16 21:10:25

==============

May 16 21:10:25

Using Nixpacks

May 16 21:10:25

==============

May 16 21:10:25

May 16 21:10:25

context: t7nc-ymse

May 16 21:10:25

╔═════════ Nixpacks v1.38.0 ═════════╗

May 16 21:10:25

║ setup │ nodejs_18, npm-9_x ║

May 16 21:10:25

║────────────────────────────────────║

May 16 21:10:25

║ install │ npm i ║

May 16 21:10:25

║────────────────────────────────────║

May 16 21:10:25

║ start │ node backend/index.js ║

May 16 21:10:25

╚════════════════════════════════════╝

May 16 21:10:25

[internal] load build definition from Dockerfile

May 16 21:10:25

[internal] load build definition from Dockerfile heavy_check_mark emoji 0ms

May 16 21:10:25

[internal] load build definition from Dockerfile

May 16 21:10:25

[internal] load build definition from Dockerfile heavy_check_mark emoji 12ms

May 16 21:10:25

[internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1745885067

May 16 21:10:26

[internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1745885067heavy_check_mark emoji 546ms

May 16 21:10:26

[internal] load .dockerignore

May 16 21:10:26

[internal] load .dockerignore heavy_check_mark emoji 0ms

May 16 21:10:26

[internal] load .dockerignore

May 16 21:10:26

[internal] load .dockerignore heavy_check_mark emoji 10ms

May 16 21:10:26

[internal] load build context heavy_check_mark emoji 0ms

May 16 21:10:26

[internal] load build context

May 16 21:10:26

[internal] load build context heavy_check_mark emoji 41ms

May 16 21:10:26

[stage-0 3/8] COPY .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix heavy_check_mark emoji 0ms – CACHED

May 16 21:10:26

[stage-0 4/8] RUN nix-env -if .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix && nix-collect-garbage -d heavy_check_mark emoji 0ms – CACHED

May 16 21:10:26

[stage-0 5/8] COPY . /app/. heavy_check_mark emoji 0ms – CACHED

May 16 21:10:26

[stage-0 6/8] RUN --mount=type=cache,id=s/84f6c431-6b4b-4ad9-bc6a-a513a3d32c7f-/root/npm,target=/root/.npm npm i heavy_check_mark emoji 0ms – CACHED

May 16 21:10:26

[stage-0 7/8] RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile heavy_check_mark emoji 0ms – CACHED

May 16 21:10:26

[stage-0 8/8] COPY . /app heavy_check_mark emoji 0ms – CACHED

May 16 21:10:26

exporting to docker image format

May 16 21:10:26

exporting to image

May 16 21:10:26

[auth] sharing credentials for asia-southeast1.registry.rlwy.net

May 16 21:10:26

[auth] sharing credentials for asia-southeast1.registry.rlwy.netheavy_check_mark emoji 0ms

May 16 21:10:28

importing to docker

May 16 21:10:31

importing to docker heavy_check_mark emoji 3s

May 16 21:10:31

=== Successfully Built! ===

May 16 21:10:31

Run:

May 16 21:10:31

docker run -it asia-southeast1.registry.rlwy.net/84f6c431-6b4b-4ad9-bc6a-a513a3d32c7f:08b13c1b-ad64-40e8-8b06-eac8975cd28e

May 16 21:10:31

Build time: 6.30 seconds


marktawa
HOBBY

7 months ago

Show me your Deploy logs


marktawa
HOBBY

7 months ago

Change your start command from "node backend/index.js" to "node index.js"


marktawa

Change your start command from "node backend/index.js" to "node index.js"

batoqqqa
FREEOP

7 months ago

Thanks, it helped


Status changed to Solved brody 7 months ago


Loading...