Nodejs Typescript server failed to deploy

Hello everyone, please I need assistance with this.
I’m trying to deploy my typescript server to render.com.
In my package.json file of my API code, I have this as my build command : “rimraf ./build && tsc”,
And I’m my render web service settings, I have in the start command to be: node ./build/src/server.js.
But this is the error log when I deploy
==> Running ‘node ./build/src/server.js’
node:internal/modules/cjs/loader:1147
throw err;
^
Error: Cannot find module ‘/opt/render/project/src/build/src/server.js’
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
code: ‘MODULE_NOT_FOUND’,
requireStack:
}

Hi there,

Error: Cannot find module ‘/opt/render/project/src/build/src/server.js’

This is letting you know that the service cannot find the the server.js file in the /build/src/ directory. Is this file present in the connected Git repository at the same path off of the root?

Regards,
Mike


Render Support Engineer, MT (UTC-6, UTC-7 in Winter)

Hello Mike,
Thanks for replying to my post.

As a response, I created a build command to build it online not locally. It doesn’t, but this is my package.json {
“build”: “rimraf build && tsc”,
“start”: “node -r module-alias/register ./build/src/server.js”,
“test”: “echo "Error: no test specified" && exit 1”,
“dev”: “SET APP_ENV=development & nodemon src/server.ts”
} for that command
The build folder is supposed to be at the root directory to hold the compiled ts files while the src folder itself is the ts files folder

Hi there,

In order to get into specific details about your service, I recommend reaching out to support privately via the “Help” link in the Dashboard. Please be sure to select the specific service you are referring to.

Regards,
Mike


Render Support Engineer, MT (UTC-6, UTC-7 in Winter)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.