TypeError: cmd is not a function

br4m11
PRO

10 months ago

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 the env vars should be correct. 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

> cross-env medusa migrations run && medusa start

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

Error: Cannot find module 'ajv/dist/core'

Require stack:

- /app/node_modules/ajv-draft-04/dist/index.js

- /app/node_modules/@rushstack/node-core-library/lib/JsonSchema.js

- /app/node_modules/@rushstack/node-core-library/lib/index.js

- /app/node_modules/@rushstack/terminal/lib/NormalizeNewlinesTextRewriter.js

- /app/node_modules/@rushstack/terminal/lib/index.js

- /app/node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.js

- /app/node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.js

- /app/node_modules/@rushstack/ts-command-line/lib/index.js

- /app/node_modules/umzug/lib/cli.js

- /app/node_modules/umzug/lib/umzug.js

- /app/node_modules/umzug/lib/index.js

- /app/node_modules/@mikro-orm/migrations/Migrator.js

- /app/node_modules/@mikro-orm/migrations/index.js

- /app/node_modules/@medusajs/utils/dist/dal/mikro-orm/mikro-orm-create-connection.js

- /app/node_modules/@medusajs/medusa-cli/dist/index.js

- /app/node_modules/@medusajs/medusa/dist/bin/medusa.js

- /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',

requireStack: [
'/app/node_modules/ajv-draft-04/dist/index.js',

'/app/node_modules/@rushstack/node-core-library/lib/JsonSchema.js',

'/app/node_modules/@rushstack/node-core-library/lib/index.js',

'/app/node_modules/@rushstack/terminal/lib/NormalizeNewlinesTextRewriter.js',

'/app/node_modules/@rushstack/terminal/lib/index.js',

'/app/node_modules/@rushstack/ts-command-line/lib/providers/CommandLineParser.js',

'/app/node_modules/@rushstack/ts-command-line/lib/providers/ScopedCommandLineAction.js',

'/app/node_modules/@rushstack/ts-command-line/lib/index.js',

'/app/node_modules/@medusajs/medusa/dist/commands/utils/get-migrations.js',

'/app/node_modules/@medusajs/medusa/dist/commands/migrate.js',

'/app/node_modules/@medusajs/medusa-cli/dist/create-cli.js',

'/app/node_modules/@medusajs/medusa-cli/dist/index.js',

'/app/node_modules/@medusajs/medusa/dist/bin/medusa.js',

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

]

}

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

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)

Solved

2 Replies

10 months ago

Hey this looks like an issue with your application. You'll have to figure out what's wrong with your code. Going to make this public so maybe someone in the community can help.


Status changed to Awaiting User Response Railway 10 months ago


10 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open jake 10 months ago


br4m11
PRO

10 months ago

The problem was Error: Cannot find module 'ajv/dist/core'. So added the ajv package with npm install ajv. Worked fine after that.


Status changed to Solved brody 10 months ago


TypeError: cmd is not a function - Railway Help Station