0

I'm trying to get realm-cli running, installing it globally with the usual

npm install -g mongodb-realm-cli

It seems to install it alright, I can see it in Users/<Username>/AppData/Roaming/npm. There is the executable file without extension with contents below

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  exec "$basedir/node"  "$basedir/node_modules/mongodb-realm-cli/wrapper.js" "$@"
else 
  exec node  "$basedir/node_modules/mongodb-realm-cli/wrapper.js" "$@"
fi

As well as a .cmd and .ps1 files.

When I run a test command "realm-cli --profile --help", I get the error:

C:\Users\<Username>\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

Right now, logging "where npm" gives me:

C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\<Username>\AppData\Roaming\npm\npm
C:\Users\<Username>\AppData\Roaming\npm\npm.cmd

And "which npm" gives:

/c/Program Files/nodejs/npm

I'm guessing it's some issue with either versions or installation directory for Node.js but I'm unsure how to fix it.

The ProgramFiles folder seems to contain the actual npm executable, whereas the Roaming/npm folder contains the globally installed packages. So I'm not sure these logs show any problem.

I tried adding the Roaming/npm folder to environmental variable path but it was no help. I made sure to put the variable in both User and System variables just in case, and always before any other mention of npm/node.

Of course I also tried uninstalling, clearing the npm cache and reinstalling the package. I tried other packages also to make sure it wasn't an isolated issue.

Any help or clues? Thanks


EDIT/SOLVED: I believe something must've went wrong a while ago when I tried to install NVM without properly removing all Node.js files first. I did a complete uninstall of Node.js and NVM (using the solution listed here as ref), and reinstalled NVM (and Node.js through NVM). Now it works fine.

latinsniper
  • 121
  • 2
  • 15
  • @JBallin You might be right, but unfortunately that's not the issue. I've tried other commands (even just -h/--help), and other packages (yarn, hello-world-npm, tree). It's something wrong with the global installations in general. – latinsniper Feb 28 '23 at 20:58

0 Answers0