Amplify-cli: 'amplify configure' not working on windows (cmd.exe)

Created on 24 Aug 2018  ·  26Comments  ·  Source: aws-amplify/amplify-cli

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Running 'amplify configure' returns "Error: you are not working inside a valid amplify project"

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
1) Create an empty folder
2) Run 'amplify configure'
3) See the above error

What is the expected behavior?
It should work properly on an empty folder. It should not require an amplify project.

Which versions of Amplify CLI, and which OS are affected by this issue? Did this work in previous versions?
npm installed the latest version of the CLI as of 8/24/2018. Running on Windows 10.

windows

Most helpful comment

For all experiencing the issue of Windows Command Prompt not recognizing amplify, the reason behind this error being windows unable to detect PATH to the amplify's executable file.

To solve this, simply edit a PATH key under system Environment Variables and add a new path pointing to amplify. For me it's:

C:\Users\YourUserAccountName\AppData\Roaming\npm\

If you have globally installed amplify/cli then you should find two files named amplify and amplify.cmd in the above mentioned npm directory.

That's all ! I hope it solves this problem for all of you experiencing it 😄

All 26 comments

@mohitsriv Did you have any beta CLI builds installed from before?

I'm seeing the same issue (also applied to Powershell). As the amplify CLI tool is installed globally, I don't think the empty folder is necessary for this. It should just simply work anywhere.

I'm seeing it on a fresh install of Windows 10 with no previous betas installed.

Versions:
node v10.9.0
npm v6.2.0
Windows 10 Pro (fresh install)

Error: you are not working inside a valid amplify project
    at getAmplifyDirPath (MY_NODE_DIRECTORY\node_modules\@aws-amplify\cli\src\extensions\amplify-helpers\path-manager.js:57:9)
    at getDotConfigDirPath (MY_NODE_DIRECTORY\node_modules\@aws-amplify\cli\src\extensions\amplify-helpers\path-manager.js:63:5)
    at Object.getProjectConfigFilePath (MY_NODE_DIRECTORY\node_modules\@aws-amplify\cli\src\extensions\amplify-helpers\path-manager.js:100:5)
    at Object.getProjectDetails (MY_NODE_DIRECTORY\node_modules\@aws-amplify\cli\src\extensions\amplify-helpers\get-project-details.js:5:45)
    at Command.run (MY_NODE_DIRECTORY\node_modules\@aws-amplify\cli\node_modules\amplify-category-hosting\commands\hosting\configure.js:7:39)
    at Runtime.<anonymous> (MY_NODE_DIRECTORY\node_modules\@aws-amplify\cli\node_modules\gluegun\build\runtime\run.js:90:58)
    at step (MY_NODE_DIRECTORY\node_modules\@aws-amplify\cli\node_modules\gluegun\build\runtime\run.js:32:23)
    at Object.next (MY_NODE_DIRECTORY\node_modules\@aws-amplify\cli\node_modules\gluegun\build\runtime\run.js:13:53)

I've uninstalled the npm module and installed from source. Confirmed that the updated messages is now displaying, but I have the same issue after running amplify configure in a random directory.

C:\dev\amplify-cli\packages\amplify-cli\node_modules\gluegun\build\index.js:13
    throw up;
    ^

Error: You are not working inside a valid amplify project.
Use 'amplify init' in the root of your app directory to initialize your project with Amplify
    at getAmplifyDirPath (C:\dev\amplify-cli\packages\amplify-cli\src\extensions\amplify-helpers\path-manager.js:58:9)
    at getDotConfigDirPath (C:\dev\amplify-cli\packages\amplify-cli\src\extensions\amplify-helpers\path-manager.js:64:5)
    at Object.getProjectConfigFilePath (C:\dev\amplify-cli\packages\amplify-cli\src\extensions\amplify-helpers\path-manager.js:101:5)
    at Object.getProjectDetails (C:\dev\amplify-cli\packages\amplify-cli\src\extensions\amplify-helpers\get-project-details.js:5:45)
    at Command.run (C:\dev\amplify-cli\packages\amplify-category-hosting\commands\hosting\configure.js:7:39)
    at Runtime.<anonymous> (C:\dev\amplify-cli\packages\amplify-cli\node_modules\gluegun\build\runtime\run.js:90:58)
    at step (C:\dev\amplify-cli\packages\amplify-cli\node_modules\gluegun\build\runtime\run.js:32:23)
    at Object.next (C:\dev\amplify-cli\packages\amplify-cli\node_modules\gluegun\build\runtime\run.js:13:53)
    at C:\dev\amplify-cli\packages\amplify-cli\node_modules\gluegun\build\runtime\run.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (C:\dev\amplify-cli\packages\amplify-cli\node_modules\gluegun\build\runtime\run.js:3:12)
    at Runtime.run (C:\dev\amplify-cli\packages\amplify-cli\node_modules\gluegun\build\runtime\run.js:51:12)
    at Object.run (C:\dev\amplify-cli\packages\amplify-cli\src\cli.js:20:29)
    at Object.<anonymous> (C:\dev\amplify-cli\packages\amplify-cli\bin\amplify:3:23)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)

Quick note, since I mentioned running configure on Windows in a different ticket - I do get this issue if I run in an empty directory. However, if I run init first, then configure, it runs fine.

@mwarger @ericathegreat @mohitsriv we’re seeing some anomalous behavior on windows due to the filesystem. We’ll be figuring out a solution in the next couple of days and get back to you on this thread.

I have the same issue with amplify configure

Windows 10 here

"amplify configure" gives "Error: You are not working inside a valid amplify project."

"amplify init" asks me to choose a Default editor. I select "Visual Studio Code. It then prompts for the type of app that you're building but instead of allowing selecting, I get thrown back to the powershell prompt. (ticket #34 opened for this issue as it seems to be different)

Trying "amplify configure" after the failed "amplify init" results in the same "You are not working inside a valid Amplify project" error.

I thought I would try the Windows Subsystem on Linux (WSL) but when I run aws configure:

root@DESKTOP-LU92RCU:/mnt/c/users/bradt/Documents/Cs/react/amplif# amplify configure
Follow these steps to set up access to your AWS account:

Sign in to your AWS administrator account:
https://console.aws.amazon.com/
Press Enter to continue
2018-08-27T12:32:30.673Z - error: uncaughtException: spawn cmd.exe ENOENT date=Mon Aug 27 2018 08:32:30 GMT-0400 (DST), pid=59, uid=0, gid=0, cwd=/mnt/c/users/bradt/Documents/Cs/react/amplif, execPath=/usr/bin/node, version=v8.11.4, argv=[/usr/bin/node, /usr/bin/amplify, configure], rss=116506624, heapTotal=94609408, heapUsed=64301088, external=669752, loadavg=[0.5185546875, 0.57763671875, 0.5859375], uptime=1067, trace=[column=11, file=util.js, function=_errnoException, line=992, method=null, native=false, column=19, file=internal/child_process.js, function=Process.ChildProcess._handle.onexit, line=190, method=onexit, native=false, column=16, file=internal/child_process.js, function=onErrorNT, line=372, method=null, native=false, column=11, file=internal/process/next_tick.js, function=_combinedTickCallback, line=138, method=null, native=false, column=9, file=internal/process/next_tick.js, function=process._tickCallback, line=180, method=_tickCallback, native=false, column=11, file=module.js, function=Module.runMain, line=695, method=runMain, native=false, column=16, file=bootstrap_node.js, function=startup, line=191, method=null, native=false, column=3, file=bootstrap_node.js, function=null, line=612, method=null, native=false], stack=[Error: spawn cmd.exe ENOENT,     at _errnoException (util.js:992:11),     at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19),     at onErrorNT (internal/child_process.js:372:16),     at _combinedTickCallback (internal/process/next_tick.js:138:11),     at process._tickCallback (internal/process/next_tick.js:180:9),     at Function.Module.runMain (module.js:695:11),     at startup (bootstrap_node.js:191:16),     at bootstrap_node.js:612:3]

@bradthurber I see the same amplify init behavior as well. I believe it likely fails because it's not configured, but I can't prove that.

@kaustavghosh06 - is there a verbose mode for the CLI so we can get output? Are logs saved somewhere? Would be happy to provide any assistance.

@bradthurber again - I had a hell of a time getting amplify to work after installing it on WSL. I had to reinstall once and then it worked. At that point, parts of the dependencies for Amplify were all referencing /mnt/c in their path and would not work any longer in the "regular" windows 10 cmd/powershell. I couldn't figure out how to unlink the npm library so it appeared stuck to WSL even after uninstalling WSL. My lack of deep npm knowledge probably led me astray, but I ended up formatting my system to reset everything (not a big deal, takes 30 minutes). 😞

Hey guys, so I tried using the CLI with the Windows Linux susbsytem (WSL) on windows and it works fine so far. Highly encourage using WSL for your Amplify project development. We have updated our main README with the following.

If you're using Windows, the CLI currently supports [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10).

In the meanwhile we're trying to figure out the rootcause of the erroneous behavior of the CLI with the windows filesystem.

Just an FYI - if you want to run the commands in VSCode on windows or another powershell window, you can prefix them with wsl. So amplify add hosting would become wsl amplify add hosting. This will forward them to WSL and run them using the amplify install in the linux system.

This issue should be fixed with the latest version of the CLI. Feel free to re-open if the problem still persists.

Unfortunatly it is not solved under Windows 10

G:\Code\temp\myapp>node -v
v10.11.0

G:\Code\temp\myapp>npm -v
6.4.1

G:\Code\temp\myapp>amplify init
_Note:_ It is recommended to run this command from the root of your app directory
? Choose your default editor: Sublime Text
? Choose the type of app that you're building (Use arrow keys)
android
ios

javascript_

G:\Code\temp\myapp>amplify add auth
_C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clinode_modules\gluegun\buildindex.js:13_
throw up;
^

Error: You are not working inside a valid amplify project.
Use 'amplify init' in the root of your app directory to initialize your project with Amplify
at getAmplifyDirPath (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clisrcextensionsamplify-helpers\path-manager.js:57:9)
at getDotConfigDirPath (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clisrcextensionsamplify-helpers\path-manager.js:63:5)
at Object.getProjectConfigFilePath (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clisrcextensionsamplify-helpers\path-manager.js:99:5)
at Object.getProjectDetails (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clisrcextensionsamplify-helpersget-project-details.js:5:45)
at run (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clinode_modulesamplify-category-auth\commands\auth\enable.js:15:34)
at Command.run (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clinode_modulesamplify-category-auth\commands\auth.js:9:16)
at Runtime. (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clinode_modules\gluegun\build\runtime\run.js:90:58)
at step (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clinode_modules\gluegun\build\runtime\run.js:32:23)
at Object.next (C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clinode_modules\gluegun\build\runtime\run.js:13:53)
at _C:\Users\GridAppData\Roamingnpmnode_modules\@aws-amplify\clinode_modules\gluegun\build\runtime\run.js:7:71_

@gridknight Which version of the CLI are you running? You can run ‘amplify -v’ to check it.

@kaustavghosh06 I am using 0.1.24

G:\Code\temp\myapp>amplify -v
0.1.24

Tried
npm install -g @aws-amplify/cli
Has not changed anything.

amplify configure works without a problem. Anything else seams to be not working

I am running version 0.1.27

When I do amplify configure it seems to work ok. Then I do amplify init and I get a similar problem where I am not allowed to chose android or ios. Then finally, get init is still having the same problem.

Just wondering if there is a fix as of 10/3

Thanks

Same here as @TylerKann & @bradthurber etc.
Also running version 0.1.27 on Windows 10
Any updates?

One of my pc's is running 0.1.29 and it worked fine. another one can't choose the type of app i'm building because it dumps to the command line with no error message.

Same issue as @stevegula using PowerShell and:

❯ amplify -v
0.1.31

We published a new version of the CLI to npm, version -> 0.1.32 with fixes for windows. Feel free to re-open the issue if the problem still persists.

$ amplify -v 0.1.36

$ npm -v 6.4.1

$ node -v v8.14.0

.../node_modules/@aws-amplify/cli/node_modules/gluegun/build/index.js:13 Error: Cannot find module 'awscloudformation'
trying a reinstall - nothing changed

If you are having difficulties using amplify on windows (which seems to be the case for many, many people), I was able to run it inside of visual studio code by providing the full path of the amplify command to the windows subsystem for linux, and the specific amplify command to run (init in this example). Windows Subsystem for Linux requires forward slashes and puts the C: drive under /mnt as /mnt/c (lowercase)

PS C:\My Folder> wsl /mnt/c/Users/MyUsername/AppData/Roaming/npm/node_modules/@aws-amplify/cli/bin/amplify init

For all experiencing the issue of Windows Command Prompt not recognizing amplify, the reason behind this error being windows unable to detect PATH to the amplify's executable file.

To solve this, simply edit a PATH key under system Environment Variables and add a new path pointing to amplify. For me it's:

C:\Users\YourUserAccountName\AppData\Roaming\npm\

If you have globally installed amplify/cli then you should find two files named amplify and amplify.cmd in the above mentioned npm directory.

That's all ! I hope it solves this problem for all of you experiencing it 😄

In order for it to work for me I put the executable files in the PATH in Environment Variables like waleedshkt said. Then at the command prompt I typed:
c:\Users\YOUAppdata\Roamingnpmamplify.cmd configure

Perm fix required, 2020

None of the above worked, unable to located or find amplify.cmd anywhere.
Appdata\Roamingnpm < does not exist

node -v 10.19.0
amplify -v 4.19.0
npm -v 6.14.4

Literally the same issue everyone else has commented on.

In this issue thread for some reason are merged different problems. I highly advise to not referring to "all above" and quote fragments that you are referring to.

Let's divide this thread into "Issue about amplify configure" and "Issue about amplify is not recognized as a command".

node v12.10.0
npm 6.14.5
amplify 4.19.0
(But I think node/npm version has nothing to do with errors)

I am wsl user.

System information:
Info about my wsl and distro (please provide this as it might be required to spot differences):
ver in cmd:
Microsoft Windows [Version 10.0.18363.778]
Can't verify my wsl/distros versions (from the windows side) due to wsl --list --verbose returning help of wsl instead of versions. (Help needed)
In wsl - cat /proc/version
Linux version 4.4.0-18362-Microsoft ([email protected]) (gcc version 5.4.0 (GCC) ) #476-Microsoft Fri Nov 01 16:53:00 PST 2019
And my distro (in wsl grep "^PRETTY_NAME" /etc/*release)
Debian GNU/Linux 10 (buster)

Both issues: please provide system information and tell me the result of those commands in wsl:
(you can get "something not found" messages there)
(remove personal data from paths)
which node
which npx
which amplify
And in case that your amplify -v is working - tell if it has been run from wsl or cmd. (provide output of amplify -v from wsl)

Issue about amplify configure: amplify configure works normally in project folders and folders not related to amplify (empty dirs too). _On my computer works_ 😅 Let's proceed with "Both issues".

Issue about amplify is not recognized as a command: it is not happening for me. _On my computer works_ 😅 Let's proceed with "Both issues".

Was this page helpful?
0 / 5 - 0 ratings