6

I wanted to install serverless in my windows 7 machine.My npm version is 6.1.0. I used the command

npm install -g serverless
C:\Users\ADMIN\AppData\Roaming\npm\serverless -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless
C:\Users\ADMIN\AppData\Roaming\npm\slss -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless
C:\Users\ADMIN\AppData\Roaming\npm\sls -> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\bin\serverless

> spawn-sync@1.0.15 postinstall C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless\node_modules\spawn-sync
> node postinstall


> serverless@1.30.1 postinstall C:\Users\ADMIN\AppData\Roaming\npm\node_modules\serverless
> node ./scripts/postinstall.js

+ serverless@1.30.1
added 351 packages from 269 contributors in 154.064s

But when I type serverless in command prompt, it tells me

'serverless' is not recognized as an internal or external command,
operable program or batch file.
Subhendu Mahanta
  • 961
  • 1
  • 18
  • 44
  • The search string you're looking for here is *not recognized as an internal or external command*, which will find you many existing questions here. They won't contain *serverless*, but the solution is the same for most of them. – Ken White Aug 17 '18 at 02:31
  • This happened to me today after performing a Windows update. Had to reinstall serverless to get rid of this issue. – Pavindu Jul 11 '21 at 12:03

5 Answers5

7

I had the same issue and I believe you are missing the npm path from your environment variables.

Go to Windows search and type: "Edit the system environment variables" (at least this is how you can find the Environment Variables in Windows 10).

Go to Advanced tab and click on Environment Variables.

Select Path from the User Variables and click Edit.

Click New and provide the following: C:\Users[USER_NAME]\AppData\Roaming\npm\ or whatever is the path that you have installed npm - just change the [USER_NAME] with your username account.

Else you could navigate to the path above and execute "serverless" from inside that path.

Hope that helps :)

spiros
  • 369
  • 4
  • 11
4

Try make use of npx

Example:

npx sls deploy
UberGeoff
  • 192
  • 6
0

I had the same issue. In my Windows 10 system, I wanted to install serverless under Git Bash.

I was able to install serverless with the normal account just fine, but then the serverless command was not found (even after closing Git Bash and launching it again). After doing the same steps using Administrator privileges, everything worked fine even using the normal user account. Perhaps this will help someone.

jMike
  • 9
  • 3
0

^^Adding both environment paths, to npm and serverless/bin, worked for me. Same issue. Windows 10, trying to start a Serverless project after it seemingly installed correctly.

Going to it from /npm also worked, but the adding both environment paths was the permanent solution by @Suday Ghosh

-1

Go to System Window (Control Panel\System and Security\System);

Click "Advanced System Settings"

Click "Environment Variables"

Select "Path" variables and click "Edit" Button

Under "Edit environment variable" window, Click "New" Button

Provide the following paths separately: C:\Users[USER_NAME]\AppData\Roaming\npm\

AND

C:\Users[USER_NAME]\AppData\Roaming\npm\node_modules\serverless\bin

Happy !!!!!!