20

I installed NodeJS, which seems to work fine. Running npm worked fine and I could install packages. Then I ran

npm install serverless -g

which also ran fine. But when I try to run:

serverless

at the windows command prompt, I get an error about the command not being found.

'serverless' is not recognized as an internal or external command,
operable program or batch file.

I've included the answer is below.

Ryan Shillington
  • 19,533
  • 12
  • 88
  • 99

4 Answers4

25

The issue for me was that I was missing the following directory in my Windows PATH env variable:

%AppData%\npm

Once I added that, I could run serverless, sls, etc.

Ryan Shillington
  • 19,533
  • 12
  • 88
  • 99
7

This is probably a stupid answer, but might help someone i hope.

I was facing the same problem, even after adding the path. I found that my AppData folder was hidden somehow, making it available fixed the issue for me. (also after making the changes don't forget to open a new CMD :D )

Niveditha Karmegam
  • 732
  • 11
  • 27
6

I had the same issue, when i run the Command Prompt as Administrator it works fine.

Rolwin Crasta
  • 4,061
  • 3
  • 32
  • 44
0

I have a stupid answer, too: I had used nvm to change my node version last week. I had changed back to the same version in the meantime, but you still have to install serverless again then.

G-Unit
  • 1,183
  • 10
  • 33