error: undefined variable 'npm'

br4m11
PRO

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

Solved

3 Replies

10 months ago

Try removing the setup phase and it's contents.


Status changed to Awaiting User Response railway[bot] 10 months ago


br4m11
PRO

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

Sep 23 12:46:27

npm WARN config production Use --omit=dev instead.

Sep 23 12:46:27

Sep 23 12:46:27

> medusa-starter-default@0.0.1 start:server

Sep 23 12:46:27

> medusa migrations run && medusa start

Sep 23 12:46:27

Sep 23 12:46:28

--------------- ERROR ---------------------

/app/node_modules/@medusajs/medusa/cli.js

Sep 23 13:19:45

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

Sep 23 13:19:45

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

Sep 23 13:19:45

at Module.require (node:internal/modules/cjs/loader:1231:19)

Sep 23 13:19:45

at require (node:internal/modules/helpers:177:18)

Sep 23 13:19:45

at Object.<anonymous> (/app/node_modules/ajv-draft-04/dist/index.js:4:16)

Sep 23 13:19:45

at Module._compile (node:internal/modules/cjs/loader:1364:14)

Sep 23 13:19:45

at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)

Sep 23 13:19:45

at Module.load (node:internal/modules/cjs/loader:1203:32)

Sep 23 13:19:45

at Module._load (node:internal/modules/cjs/loader:1019:12)

Sep 23 13:19:45

at Module.require (node:internal/modules/cjs/loader:1231:19) {

Sep 23 13:19:45

code: 'MODULE_NOT_FOUND',

-------------------------------------------

Sep 23 13:19:43

medusa migrations [action]

Sep 23 13:19:43

Sep 23 13:19:43

Manage migrations from the core and your own project

Sep 23 13:19:43

Sep 23 13:19:43

Options:

Sep 23 13:19:43

--verbose Turn on verbose output [boolean] [default: false]

Sep 23 13:19:43

--no-color, --no-colors Turn off the color in output [boolean] [default: false]

Sep 23 13:19:43

--json Turn on the JSON logger [boolean] [default: false]

Sep 23 13:19:43

--action [required] [choices: "run", "revert", "show"]

Sep 23 13:19:43

-h, --help Show help [boolean]

Sep 23 13:19:43

-v, --version Show the version of the Medusa CLI and the Medusa package in the current project [boolean]

Sep 23 13:19:43

TypeError: cmd is not a function

Sep 23 13:19:43

at /app/node_modules/@medusajs/medusa-cli/dist/create-cli.js:152:20

Sep 23 13:19:43

at /app/node_modules/@medusajs/medusa-cli/dist/create-cli.js:48:30

Sep 23 13:19:43

at Object.handler (/app/node_modules/@medusajs/medusa-cli/dist/create-cli.js:16:21)

Sep 23 13:19:43

at Object.runCommand (/app/node_modules/yargs/build/lib/command.js:196:48)

Sep 23 13:19:43

at Object.parseArgs [as parseArgs] (/app/nodemodules/yargs/build/lib/yargs.js:1043:55)

Sep 23 13:19:43

at Object.parse (/app/node_modules/yargs/build/lib/yargs.js:584:29)

Sep 23 13:19:43

at exports.default (/app/node_modules/@medusajs/medusa-cli/dist/create-cli.js:353:10)

Sep 23 13:19:43

at Object.<anonymous> (/app/node_modules/@medusajs/medusa-cli/dist/index.js:38:26)

Sep 23 13:19:43

at Module._compile (node:internal/modules/cjs/loader:1364:14)

Sep 23 13:19:43

at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)


Status changed to Awaiting Railway Response railway[bot] 10 months ago


br4m11
PRO

10 months ago

removed


Status changed to Solved jake 10 months ago