amplify-cli: "Select the backend providers" is empty when using npx

Describe the bug A clear and concise description of what the bug is.

Running amplify configure prompted to Select the backend providers, but screen is blank. Pressing ENTER terminates program.

To Reproduce Steps to reproduce the behavior:

  1. Run npx amplify configure
  2. Observe blank screen under prompt
  3. Press ENTER (optional)
  4. Observe command finishes

Expected behavior To see prompt options.

Screenshots

image

Desktop (please complete the following information):

  • OS: MacOS 10.14.3
  • npx: 9.7.1
  • amplify-cli: 0.1.45

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 24 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I have had the same symptoms when I installed the cli with sudo yarn global add @aws-amplify/cli.

Yarn chose to install the amplify command under /usr/local/bin as a symlink to /usr/local/share/.config/yarn/global/node_modules/.bin/amplify. However, the contents of the main amplify script were:

#!/usr/bin/env node
// run the CLI with the current process arguments
require('../src/cli').run(process.argv)

After removing the package with sudo yarn global remove @aws-amplify/cli and reinstalling with sudo npm install -g @aws-amplify/cli, it works correctly. The script linked to is still the same, but the link is stored at /usr/bin/amplify and points to /usr/lib64/node_modules/@aws-amplify/cli/bin/amplify.

The difference is that yarn is copying installed bin scripts into .bin, which does not have the adjacent src directory as expected because it is not running from the @aws-amplify/cli directory.

I’m still hitting this exact issue. Installed with yarn global add @aws-amplify/cli.

image

I confirmed today this problem still exists for local installs via yarn and run via npx.

I have the exact same bug as @daviskoh.

And like @dave-moser, I am also trying to use npx as an alternative to doing a global install of Amplify (because global install is a deprecated method in general).

Here is my package.json:

dependencies: {
     ...
     "aws-amplify": "^2.2.7",
     ...
},
devDependencies: {
     ...
     "@aws-amplify/cli": "^4.17.2",
     ...
}

This issue should be re-opened, it’s a pretty frustrating bug.

Yes, everything works fine if I have Amplify installed globally. I am trying to use npx as an alternative to doing a global install of Amplify - where Amplify is a devDependency local to the project.

Above when you said “the latest version of amplify cli works with npx” I interpreted that as being able to use it locally without a global install.

@kaustavghosh06 thanks, that works. Didn’t realize I couldn’t use yarn.

@UnleashedMind You’re right; - it does ultimately point to the bin directory of @aws-amplify/cli, so resolving ../src/cli shouldn’t be the problem. In fact, that seems obvious in retrospect, since it’s obviously doing something. The problem seems to be that it’s not correctly locating the other node modules.

I think the problem may be related to the fact that I installed via sudo, and the system-level yarn packages are not discovered correctly.

When I originally tried yarn global add @aws-amplify/cli without sudo, I got errors preventing installation. It tries to install fsevents, which has event-stream "~3.3.0" as a dependency. That resolves to event-stream-3.3.6, which is listed as a version in the yarn registry, but for some reason is not actually available. The latest ~3.3.0 version actually available for download is 3.3.5. It fails to retrieve 3.3.6 with a 404 error, and gives up on installing in the $HOME/.config/yarn/global directory.

I installed with sudo, and instead of silently installing fsevents and failing on event-stream, it said linux was not compatible with fsevents and decided not to install it as an optional dependency. I don’t know why it behaved differently, but the result is that it did not try to install event-stream and succeeded.

The empty providers problem is caused by the different install location. The yarn prefix code detection code fails, because it’s not running from $HOME/.config/yarn/global, but in /usr/local/share/.config/yarn/global. Yarn doesn’t install recursive node_modules in the @aws-amplify/cli directory, so the local node_modules detection returns nothing. Meanwhile, even though I have had it installed with sudo npm install -g at the same time, npm only installs the top package in the global /usr/lib/node_modules directory; all of the other dependencies get installed in a local recursive node_modules location, so those can’t be found that way either. Consequently, no plugins are found when installed via sudo yarn global add.

If that’s the case, then I guess this should be made separate issues for installing with yarn, both to fix the fsevents installation issue, and support sudo global add. It does give a hint that npx may be having the same issues with node_modules plugin detection too though.

I noticed the same behavior when attempting to install amplify/cli into my project (with npm) as opposed to installing it globally.

I’m seeing this with

dependencies: {
     ...
     "aws-amplify": "^1.1.19",
     ...
},
devDependencies: {
     ...
     "@aws-amplify/cli": "^0.2.1-multienv.42",
     ...
}

tried both: npx amplify init and ./node_modules/.bin/amplify init

But: It does work when using the npm i -g version, which is a decent workaround but not ideal for those of us who expect projects to be self containing So in my case: npm i -g @aws-amplify/cli@0.2.1-multienv.42 and using the globally available $> amplify this issue goes away on all the subcommands that depend on OP’s CLI question