Search code examples
aws-sam-cli

Installed SAM in C:\ but code in D:\ 'sam' is not recognized as an internal or external command


I have installed SAM CLI in C Drive but my codes are in D Drive. As such, in my VSCode, when i try to run "sam init" or "same --version", it throws back an error of 'sam' is not recognized as an internal or external command,operable program or batch file. How can I fix this issue to allow myself to run from D Drive? Or is this not possible?

location of SAM in C Drive

Code project location

Error message in VSCode


Solution

  • You need to add that folder into your environment PATH so that your terminal can find the program.

    If you type environment in the windows search bar it should be one of the first results.

    https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537574(v=office.14)

    Update:

    For clarity, you need to restart your terminal as when it opens it will run through a set of initialisation actions to load its own environment (e.g. one of which is setting its PATH environment variable).

    When you try and run an executable file, the windows terminal will search the current folder and every folder declared in the PATH to try and find it to run.