amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Can't add third-party NPM plugins since Amplify CLI v8.0.0

Open LaurensBrinker opened this issue 2 years ago • 3 comments

Before opening, please confirm:

  • [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

14.19.1 (but I checked and the error is also there for v16.14.2, so seems Node version doesn't affect it)

Amplify CLI Version

8.0.0

What operating system are you using?

Ubuntu, Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Amplify Categories

Not applicable

Amplify Commands

add

Describe the bug

I'm one of the authors of this third-party Amplify plugin: https://www.npmjs.com/package/amplify-graphql-seed-plugin

In previous versions of the Amplify CLI, our users could install our plugin using NPM directly following the method described in the following official Amplify documentation:

npm install -g amplify-graphql-seed-plugin
amplify plugin add amplify-graphql-seed-plugin

However, since Amplify CLI version 8.0.0, this is no longer working. Instead, when running the same commands, the following error emerges:

$ npm install -g amplify-graphql-seed-plugin
$ amplify plugin add amplify-graphql-seed-plugin
Can not locate the plugin package.
? Enter the absolute path for the root of the plugin directory:

This is not an issue with our Plugin specifically, as e.g. this plugin can't be added either.

Two workarounds described below:

  • Downgrade Amplify version
  • Clone source-code of Plugin from GitHub to project, and add plugin by providing absolute path (undesirable since this increases the complexity of adoption of plugin, especially in CI/CD pipelines)

Expected behavior

$ npm install @aws-amplify/cli
$ npm install -g amplify-graphql-seed-plugin
$ amplify plugin add amplify-graphql-seed-plugin
Plugin package found.
/home/ec2-user/.nvm/versions/node/v16.14.2/lib/node_modules/amplify-graphql-seed-plugin
? Confirm to add the plugin package to your Amplify CLI. Yes
Successfully added plugin package.

(note: tested this with node v16 as well, had to explicitly install 7.6.26 to make it work)

Reproduction steps

Steps:

  1. npm install @aws-amplify/cli (to install version 8.0.0)
  2. npm install -g amplify-graphql-seed-plugin (to install our plugin - link to NPM / GitHub)
  3. amplify plugin add amplify-graphql-seed-plugin

Output:

Can not locate the plugin package.
? Enter the absolute path for the root of the plugin directory:

GraphQL schema(s)

No response

Log output

Don't think there's anything meaningful in here, but for completeness:

For version 7.6.26

# Put your logs below this line
2022-04-10T20:14:45.547Z|info : amplify plugin core add amplify-graphql-seed-plugin 
2022-04-10T20:14:45.608Z|info : amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}

For version 8.0.0

2022-04-10T20:17:06.206Z|info : amplify version core  
2022-04-10T20:17:16.469Z|info : amplify plugin core add amplify-graphql-seed-plugin 
2022-04-10T20:17:16.510Z|info : amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}

Additional information

Workaround 1:

"Workaround" -> downgrade Amplify version:

npm install -g @aws-amplify/[email protected] 
npm install -g amplify-graphql-seed-plugin
amplify add plugin amplify-graphql-seed-plugin

Output:

Plugin package found.
/home/ec2-user/.nvm/versions/node/v16.14.2/lib/node_modules/amplify-graphql-seed-plugin
? Confirm to add the plugin package to your Amplify CLI. Yes
Successfully added plugin package.

Workaround 2:

This works, but is undesirable - it increases complexity for the user, and makes it more difficult to integrate this in CI/CD pipelines. As running NPM packages worked quite well.

git clone https://github.com/awslabs/amplify-graphql-seed-plugin
cd amplify-graphql-seed-plugin
npm install
amplify plugin add
<provide full path to plugin>

LaurensBrinker avatar Apr 10 '22 20:04 LaurensBrinker

Hey @LaurensBrinker :wave: thanks for raising this! I was able to successfully reproduce this behavior using the provided steps. Marking as a bug 🙂

josefaidt avatar Apr 11 '22 14:04 josefaidt

Hi @josefaidt, any updates on this one? Appreciate that this is in your bug bash, but our users have been having to use our Amplify plugin with an outdated Amplify CLI for 3 months now, so would be keen to be able to allow users to use the latest version. Thanks

LaurensBrinker avatar Jul 13 '22 09:07 LaurensBrinker

@josefaidt This PR is aiming to be able to solve the issue: https://github.com/jonschlinkert/global-prefix/pull/29

The issue is described here: https://github.com/jonschlinkert/global-prefix/issues/30

It's related to amplify-cli package being unable to locate the global location of npm (and search there for plugins) since there's a bug in a module global-prefix that prevents self-executable processes (like amplify) from getting the correct path.

MorCohenAres avatar Sep 01 '22 15:09 MorCohenAres

Resolved in release 10.7.0:

https://github.com/aws-amplify/amplify-cli/releases/tag/v10.7.0

MorCohenAres avatar Feb 03 '23 02:02 MorCohenAres

Hey @MorCohenAres thank you for taking the time to file the pull request! Glad to see the release as well! Closing issue 🙂

josefaidt avatar Feb 03 '23 21:02 josefaidt