medusa: TypeError: cmd is not a function

This error appears during ‘medusa develop’

TypeError: cmd is not a function
    at /usr/lib/node_modules/@medusajs/medusa-cli/dist/create-cli.js:260:7
    at /usr/lib/node_modules/@medusajs/medusa-cli/dist/create-cli.js:108:24
    at Object.handler (/usr/lib/node_modules/@medusajs/medusa-cli/dist/create-cli.js:54:24)
    at Object.runCommand (/usr/lib/node_modules/@medusajs/medusa-cli/node_modules/yargs/build/lib/command.js:196:48)
    at Object.parseArgs [as _parseArgs] (/usr/lib/node_modules/@medusajs/medusa-cli/node_modules/yargs/build/lib/yargs.js:1043:55)
    at Object.parse (/usr/lib/node_modules/@medusajs/medusa-cli/node_modules/yargs/build/lib/yargs.js:584:29)
    at module.exports (/usr/lib/node_modules/@medusajs/medusa-cli/dist/create-cli.js:392:6)
    at Object.<anonymous> (/usr/lib/node_modules/@medusajs/medusa-cli/dist/index.js:70:27)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

-bash-4.2# uname -a Linux ip-10-0-82-92.us-west-2.compute.internal 4.14.248-189.473.amzn2.x86_64 #1 SMP Mon Sep 27 05:52:26 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 24 (6 by maintainers)

Most upvoted comments

If you are using the official documentation and created the project using npx create-medusa-app

and if your folder structure is similar to below

/my-medusa-store
  /storefront // Medusa storefront starter
  /backend // Medusa server
  /admin // Medusa admin

Run the medusa commands inside the /backend folder. This solves my issue

DIFFERENT SOLUTION FOR THOSE ASKING FOR HELP WITH medusa user ...

for those who is getting error while running medusa user ..., just change your terminal folder to ./my-medusa-store and than run same script. Problem is that medusa script tryng to run some packages locally from deps and in medusa-admin/node_modules are missing those deps. Is even written in the doc above the script

To create a new admin user from the command line, run the following command in the directory holding your Medusa server:

Happy codding

FWIW I ran into this error too when setting up MinIO. TLDR I think (in my case) it’s a conflict with yarn v3+. I fixed the error by undoing the yarn add and re-installing with npm.

Steps to reproduce: (MacOS and node v16)

  • Fresh install with medusa new ...
  • Per the quickstart guide run yarn add medusa-file-minio (in my case with yarn v3.2.3), and add MinIO stuff to .env and medusa-config.js.
  • Run medusa develop
  • The error appears: “TypeError: cmd is not a function…”

To fix the error:

  • Run yarn remove medusa-file-minio
  • Manually delete all the files yarn added
  • Run npm install medusa-file-minio
  • Run medusa develop
  • The server starts up. No error.

Getting the same error on “medusa user”, works fine on “medusa” alone. image

That worked, I had to use a module called n to get it to use the latest node instead of stable. Thanks