aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

LexRuntime no longer installed as dependency of Amplify. "Can't resolve 'aws-sdk/clients/lexruntime' in @aws-amplify/interactions/lib/Providers" #2392

Closed jkeys-ecg-nmsu closed 5 years ago

jkeys-ecg-nmsu commented 5 years ago

Describe the bug When upgrading AWS SDK for JS and Amplify to the latest version with npm i aws-sdk@2.9.0 and npm i aws-amplify@latest, I get an error that:

Module not found: Error: Can't resolve 'aws-sdk/clients/lexruntime' in '/.../node_modules/@aws-amplify/interactions/lib/Providers'

To Reproduce Steps to reproduce the behavior:

  1. Install aws-sdk with npm install --save aws-sdk@2.9.0
  2. Install Amplify with npm install --save aws-amplify@latest
  3. Import code with import AWS from 'aws-sdk'
  4. See error

Expected behavior Upgrading aws-amplify to the latest version should require that aws-sdk be upgraded to a version containing the lex runtime.

elorzafe commented 5 years ago

@jkeys-ecg-nmsu aws-sdk@2.9.0 is from 2 years ago, probably that doesn't have lexRuntime, aws-amplify has aws-sdk as dependency (2.329.0). I suggest to not include aws-sdk as a dependency of your app. Let me know how it goes.

jkeys-ecg-nmsu commented 5 years ago

@elorzafe My app is embedding a Sumerian scene that uses Amplify's version of aws-sdk, will Sumerian still have access to aws-sdk (without tree-shaking away all the services I need in Sumerian) if it's not a direct dependency?

elorzafe commented 5 years ago

You can import aws-sdk like this (the one that uses amplify library)

import { AWS } from "@aws-amplify/core/lib/Facet";
jkeys-ecg-nmsu commented 5 years ago

Thanks for your help. We ended up resolving the issue by bootstrapping a new React app with FB's create-react-app (as opposed to simple-react-app which is what I had used to bootstrap this app previously) and copying over our source including Amplify files.

@elorzafe My new app has the amplify directory and .amplifyrc; I also noticed that one of the Amplify config files has an absolute path to the project directory. If I checkout my Amplify app -- we're using CodeCommit for our source control and have decided that we're not going to .gitignore any amp files -- and update that path, should I be in a valid Amplify project directory at that point?

elorzafe commented 5 years ago

@jkeys-ecg-nmsu that shouldnt be an issue, when you run amplify init it will add to .gitignore what is not required by the cli. In case the cli doesnt work, you can run amplify init again and that will solve the issue.

jkeys-ecg-nmsu commented 5 years ago

@elorzafe Ah fair enough, for whatever reason I got the impression that amplify init is not idempotent. I manually edited project-config.json when checked out on a different machine and amplify publish worked. It looks like that file's the only one that contains anything specific to a given machine. Is it possible to turn the absolute path for projectPath into a relative path? (So anyone with git access could checkout an Amplify project and do e.g. amplify publish without having to run amplify init. Or, maybe check to see if the project contains Amplify folders/files on any command besides amplify init, and ask to re-initialize the project if they exist?)

elorzafe commented 5 years ago

@jkeys-ecg-nmsu have you tried multi-env version of amplify-cli, that has a fix to the problem youy mention?

leozdim commented 5 years ago

For me worked to updated all aws packages npm i aws-sdk@latest aws-amplify@latest

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.