10 months ago
Hello,
I am trying to setup our medusajs project on railway. I started with trying to deploy the Medusa backend server, but I keep getting the error: undefined variable 'npm'.
I could not find much about this issue. What could be going wrong?
build config:
[build]
builder = "NIXPACKS"
buildCommand = "npm run build:backend"
[build.nixpacksPlan.phases.setup]
nixPkgs = ["nodejs", "npm"]
[variables]
MEDUSA_WORKER_MODE = 'server'
[build.nixpacksPlan.phases.install]
cmds=["npm install --legacy-peer-deps"]
[deploy]
startCommand = "medusa migrations run && medusa start"
Error log:
Sep 23 11:23:54
#8 21.36 installing 'e05605ec414618eab4a7a6aea8b38f6fbbcc8f08-env'
Sep 23 11:23:54
Sep 23 11:23:54
#8 21.86 error:
Sep 23 11:23:54
#8 21.86 … while calling the 'derivationStrict' builtin
Sep 23 11:23:54
#8 21.86 at <nix/derivation-internal.nix>:34:12:
Sep 23 11:23:54
#8 21.86 33|
Sep 23 11:23:54
#8 21.86 34| strict = derivationStrict drvAttrs;
Sep 23 11:23:54
#8 21.86 | ^
Sep 23 11:23:54
#8 21.86 35|
Sep 23 11:23:54
#8 21.86
Sep 23 11:23:54
#8 21.86 … while evaluating derivation 'e05605ec414618eab4a7a6aea8b38f6fbbcc8f08-env'
Sep 23 11:23:54
#8 21.86 whose name attribute is located at /nix/store/m8klxk6j3r647r0kiw9qfk9r81gdhyvk-source/pkgs/stdenv/generic/make-derivation.nix:334:7
Sep 23 11:23:54
#8 21.86
Sep 23 11:23:54
#8 21.86 … while evaluating attribute 'passAsFile' of derivation 'e05605ec414618eab4a7a6aea8b38f6fbbcc8f08-env'
Sep 23 11:23:54
Sep 23 11:23:54
#8 21.86 at /nix/store/m8klxk6j3r647r0kiw9qfk9r81gdhyvk-source/pkgs/build-support/trivial-builders/default.nix:69:9:
Sep 23 11:23:54
#8 21.86 68| inherit buildCommand name;
Sep 23 11:23:54
#8 21.86 69| passAsFile = [ "buildCommand" ]
Sep 23 11:23:54
#8 21.86 | ^
Sep 23 11:23:54
#8 21.86 70| ++ (derivationArgs.passAsFile or [ ]);
Sep 23 11:23:54
#8 21.86
Sep 23 11:23:54
#8 21.86 (stack trace truncated; use '--show-trace' to show the full, detailed trace)
Sep 23 11:23:54
#8 21.86
Sep 23 11:23:54
#8 21.86 error: undefined variable 'npm'
Sep 23 11:23:54
#8 21.86 at /app/.nixpacks/nixpkgs-e05605ec414618eab4a7a6aea8b38f6fbbcc8f08.nix:19:16:
Sep 23 11:23:54
#8 21.86 18| '')
Sep 23 11:23:54
#8 21.86 19| nodejs npm
Sep 23 11:23:54
#8 21.86 | ^
Sep 23 11:23:54
#8 21.86 20| ];
Sep 23 11:23:54
Sep 23 11:23:55
#8 ERROR: process "/bin/bash -ol pipefail -c nix-env -if .nixpacks/nixpkgs-e05605ec414618eab4a7a6aea8b38f6fbbcc8f08.nix && nix-collect-garbage -d" did not complete successfully: exit code: 1
Sep 23 11:23:55
Sep 23 11:23:55
-----
Sep 23 11:23:55
> [stage-0 4/10] RUN nix-env -if .nixpacks/nixpkgs-e05605ec414618eab4a7a6aea8b38f6fbbcc8f08.nix && nix-collect-garbage -d:
Sep 23 11:23:55
21.86 70| ++ (derivationArgs.passAsFile or [ ]);
Sep 23 11:23:55
21.86
Sep 23 11:23:55
21.86 (stack trace truncated; use '--show-trace' to show the full, detailed trace)
Sep 23 11:23:55
21.86
Sep 23 11:23:55
21.86 error: undefined variable 'npm'
Sep 23 11:23:55
21.86 at /app/.nixpacks/nixpkgs-e05605ec414618eab4a7a6aea8b38f6fbbcc8f08.nix:19:16:
Sep 23 11:23:55
21.86 18| '')
Sep 23 11:23:55
21.86 19| nodejs npm
Sep 23 11:23:55
21.86 | ^
Sep 23 11:23:55
21.86 20| ];
Sep 23 11:23:55
-----
Sep 23 11:23:55
Sep 23 11:23:55
Dockerfile:8
Sep 23 11:23:55
-------------------
Sep 23 11:23:55
6 |
Sep 23 11:23:55
7 | COPY .nixpacks/nixpkgs-e05605ec414618eab4a7a6aea8b38f6fbbcc8f08.nix .nixpacks/nixpkgs-e05605ec414618eab4a7a6aea8b38f6fbbcc8f08.nix
Sep 23 11:23:55
8 | >>> RUN nix-env -if .nixpacks/nixpkgs-e05605ec414618eab4a7a6aea8b38f6fbbcc8f08.nix && nix-collect-garbage -d
Sep 23 11:23:55
9 |
Sep 23 11:23:55
10 |
Sep 23 11:23:55
-------------------
Sep 23 11:23:55
ERROR: failed to solve: process "/bin/bash -ol pipefail -c nix-env -if .nixpacks/nixpkgs-e05605ec414618eab4a7a6aea8b38f6fbbcc8f08.nix && nix-collect-garbage -d" did not complete successfully: exit code: 1
Sep 23 11:23:55
Sep 23 11:23:55
Error: Docker build failed
3 Replies
Status changed to Awaiting User Response railway[bot] • 10 months ago
10 months ago
Thanks for the input. That fixed the failed builds. But now I am experiencing 2 problems with running.
First issue:
The commands called in start command are throwing TypeError: cmd is not a function. I tried doing "railway run medusa migrations run" and this was running totally fine. So why cant it do this as the start command? See part of log below.
Starting Container
npm WARN config production Use --omit=dev
instead.
> medusa-starter-default@0.0.1 start:server
> medusa migrations run && medusa start
--------------- ERROR ---------------------
/app/node_modules/@medusajs/medusa/cli.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/app/node_modules/ajv-draft-04/dist/index.js:4:16)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Module.require (node:internal/modules/cjs/loader:1231:19) {
code: 'MODULE_NOT_FOUND',
-------------------------------------------
medusa migrations [action]
Manage migrations from the core and your own project
Options:
--verbose Turn on verbose output [boolean] [default: false]
--no-color, --no-colors Turn off the color in output [boolean] [default: false]
--json Turn on the JSON logger [boolean] [default: false]
--action [required] [choices: "run", "revert", "show"]
-h, --help Show help [boolean]
-v, --version Show the version of the Medusa CLI and the Medusa package in the current project [boolean]
TypeError: cmd is not a function
at /app/node_modules/@medusajs/medusa-cli/dist/create-cli.js:152:20
at /app/node_modules/@medusajs/medusa-cli/dist/create-cli.js:48:30
at Object.handler (/app/node_modules/@medusajs/medusa-cli/dist/create-cli.js:16:21)
at Object.runCommand (/app/node_modules/yargs/build/lib/command.js:196:48)
at Object.parseArgs [as parseArgs] (/app/nodemodules/yargs/build/lib/yargs.js:1043:55)
at Object.parse (/app/node_modules/yargs/build/lib/yargs.js:584:29)
at exports.default (/app/node_modules/@medusajs/medusa-cli/dist/create-cli.js:353:10)
at Object.<anonymous> (/app/node_modules/@medusajs/medusa-cli/dist/index.js:38:26)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
Status changed to Awaiting Railway Response railway[bot] • 10 months ago
10 months ago
removed
Status changed to Solved jake • 10 months ago