22

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
  • 23,006
  • 14
  • 93
  • 108

5 Answers5

28

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
  • 23,006
  • 14
  • 93
  • 108
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
  • 742
  • 11
  • 28
6

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

Rolwin Crasta
  • 4,219
  • 3
  • 35
  • 45
1

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.

Boommeister
  • 1,591
  • 2
  • 15
  • 54
1

I just run below command and its working fine for me:

  1. This command is for installing serverless-offline which helps to run serverless application on local system npm install serverless-offline --save-dev

and then,

  1. This command is for solving 'serverless' is not recognized as an internal... issue

npm install -g serverless

ankit
  • 2,591
  • 2
  • 29
  • 54