6 months ago
I have a node.js app that I can build locally and within Railway. After the build, the deployment crashes after a few tries/seconds.
I am trying to deploy my Github dev branch to a dev deployment. My variables are set, and I tried shared variables (not sure if that is the correct way).
Here is a sample of the most recent deployment log:
Node.js v18.20.5
npm warn config production Use --omit=dev instead.
rest-express@1.0.0 start
cross-env NODEENV=production node dist/index.js node:internal/errors:496 ErrorCaptureStackTrace(err); ^ TypeError [ERRINVALIDARGTYPE]: The "paths[0]" argument must be of type string. Received undefined
at new NodeError (node:internal/errors:405:5)
at validateString (node:internal/validators:162:11)
at Object.resolve (node:path:1097:7)
at file:///app/dist/index.js:11332:18
at ModuleJob.run (node:internal/modules/esm/modulejob:195:25) at async ModuleLoader.import (node:internal/modules/esm/loader:337:24) at async loadESM (node:internal/process/esmloader:34:7)
at async handleMainPromise (node:internal/modules/runmain:106:12) { code: 'ERRINVALIDARGTYPE'
8 Replies
Deployment crashes after build: Project ID 98626934-26be-4ca3-a4a3-1f6f9ca92558
6 months ago
can you just set the node_env in the variables and remove cross-env? what's you start command?
I had the env variables entered just by using "new variable". I added each of them. Whether that way or as shared variables, I still have deployment crashes. My start command is npm start.
The build always works fine (locally and in railway via github), but keeps reporting the errors and crashing.
6 months ago
After building the project locally, can you check line 11332? That line might be trying to load some variable from the environment, which is not set properly I assume. If its an environment variable, then set it in the variables tab in railway. For a failsafe, you can add a default value too. Like this:
const foo = import.meta.env.SOME_VAR || 'default'Also, consider adding some log before that line to verify the environment variable exists and is set to the correct value. If you're trying to set the environment variable in railway via github workflow, then please share your approach of setting the environment variable.
partha11
After building the project locally, can you check line 11332? That line might be trying to load some variable from the environment, which is not set properly I assume. If its an environment variable, then set it in the variables tab in railway. For a failsafe, you can add a default value too. Like this:const foo = import.meta.env.SOME_VAR || 'default'Also, consider adding some log before that line to verify the environment variable exists and is set to the correct value. If you're trying to set the environment variable in railway via github workflow, then please share your approach of setting the environment variable.
6 months ago
Where can you see the code?
Thanks for your questions, Duchess. I went back through my code and resolved the issues. My app will now complete its build and deploy.
Duchess is only showing the notification about someone who sent a reply to your query via the help-station 😅
Nonetheless, that's great to hear that your issue is solved now
clashing
Where can you see the code?
6 months ago
The error log OP attached has this line file:///app/dist/index.js:11332:18. Even though it is a compiled file, but looking at that line might give OP an idea about where to look for the error in the original file.