1

I ran the command to install Ember.js:

npm install -g ember-cli

Then when I run:

Ember -v

I get error: "The term ember is not recognized as the name of a cmdlet, function, script file or operable program ..."

I added the system environment variable $NODE_PATH = %AppData%\npm\node_modules

I see ember-cli folder in the $NODE_PATH

This is a newly imaged machine so this may be an issue with my npm setup/configuration. How can I install ember globally?

P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348

2 Answers2

0

I added %AppData%\npm (use the full path which in my case is C:\Users\bmackey\AppData\Roaming\npm) to the system Path environment variable. I had to remove C:\Program Files\Microsoft DNX\Dnvm\ from my Path in order to stay under the 260 character limit; hopefully I won't need this. I do not know a way around the 260 character limit.

Now ember -v works.

P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
0

You need to add the path to the ember.cmd file into the powershell environment variable, note that this is different to the standard PATH environment variable.

For those that don't know, the reason you can run ember (a node module) simply by running the command ember is because when you install ember it create a ember.cmd file in your AppData folder: enter image description here

this file typically looks like this and just bootstraps node and runs the ember js file:

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\node_modules\ember-cli\bin\ember" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\node_modules\ember-cli\bin\ember" %*
)

so when you run ember from your command window or powershell it just looks for a cmd file in its PATH variable. If this doesn't have an entry pointing at the location of this cmd file it won't be able to run it.

To fix this in powershell just run the following:

[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Users\<user>\AppData\npm", [EnvironmentVariableTarget]::Machine)

Most of this is taken from the answer here.

Make sure C:\Users\<user>\AppData\npm is where NPM has deployed your ember.cmd file. I have seen this also deploy in C:\Users\<user>\AppData\Roaming\npm so it can vary.

Liam
  • 27,717
  • 28
  • 128
  • 190