amplify-js
amplify-js copied to clipboard
Could not resolve "@aws-amplify/core/internals/utils" in Angular 17 project after migration
Before opening, please confirm:
- [X] I have searched for duplicate or closed issues and discussions.
- [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.
JavaScript Framework
Angular
Amplify APIs
Not applicable
Amplify Version
v6
Amplify Categories
Not applicable
Backend
None
Environment information
# Put output below this line
Describe the bug
When running my Angular project with the new Amplify, I get this:
✘ [ERROR] Could not resolve "@aws-amplify/core/internals/utils"
../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@aws-amplify/api/dist/esm/index.mjs:4:25:
4 │ export { ApiError } from '@aws-amplify/core/internals/utils';
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@aws-amplify/core/internals/utils" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
Expected behavior
No error
Reproduction steps
Not sure, I am getting this in my current Angular project, but in a new test project where I tested out Amplify 6 with Angular 17, I dont get this error.
One difference is that the test project is installed via npm, and my production project is using PNPM for package management. Not sure if that is relevant.
Code Snippet
// Put your code below this line.
Log output
// Put your logs below this line
✘ [ERROR] Could not resolve "@aws-amplify/core/internals/utils"
../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@aws-amplify/api/dist/esm/index.mjs:4:25:
4 │ export { ApiError } from '@aws-amplify/core/internals/utils';
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@aws-amplify/core/internals/utils" as external to exclude it from the
bundle, which will remove this error and leave the unresolved path in the bundle.
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
Hey @mattiLeBlanc . Are you attempting to import the API
error ? The '@aws-amplify/core/internals/utils' path is used internally only. You could use this import { ApiError } from "aws-amplify/api"
public path instead.
Hi @israx,
no, I am not using the ApiError at all. For my graphql API service I use
import { GraphQLResult, generateClient } from 'aws-amplify/api';
and for my authService I use:
import { signIn, signOut, getCurrentUser, fetchAuthSession, AuthUser, updateUserAttribute, SignInOutput, confirmSignIn } from 'aws-amplify/auth';
I have the same code in a new clean Angular project for testing purposes and there I am not getting this error. So maybe my mono repo is causing an issue because I have my Admin app now running Amplify 6, but my Client Angular app is still on Amplify 5.4. Could that cause a conflict in PNPM ?
I removed all amplify 5.4 references, removed all node_modules in projects and in the root. Still same error.
I also checked and my test app (which workks) is using "builder": "@angular-devkit/build-angular:application",
, the app that fails to build is using the same builder.
I am not sure what is causing the issue atm,
Can you share your package.json
? , so we can reproduce the issue with the same dependencies you are using.
This for the Admin project in my monorepo:
{
"name": "@apollo/admin",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host apollo-admin-app --port 4203 --open --configuration development",
"build": "./../../scripts/build-angular.sh",
"build-dev": "ng build --configuration development",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"createVersionFile": "node create-version.js",
"extract-translations": "ngx-translate-extract --input ./src --output ./src/assets/i18n/en.json --sort --format namespaced-json --marker _",
"deploy": "cdk deploy --require-approval never",
"cdk": "cdk"
},
"private": true,
"dependencies": {
"@angular/animations": "^17.0.8",
"@angular/cdk": "^17.0.4",
"@angular/common": "^17.0.8",
"@angular/compiler": "^17.0.8",
"@angular/core": "^17.0.8",
"@angular/forms": "^17.0.8",
"@angular/material": "^17.0.4",
"@angular/platform-browser": "^17.0.8",
"@angular/platform-browser-dynamic": "^17.0.8",
"@angular/router": "^17.0.8",
"@iplab/ngx-file-upload": "^17.0.0",
"aws-amplify": "^6.0.17",
"axios": "^1.3.4",
"dayjs": "^1.11.7",
"material-icons": "^1.13.12",
"rxjs": "~7.8.0",
"tailwindcss": "^3.3.5",
"tslib": "^2.3.0",
"uuid": "^9.0.1",
"zone.js": "~0.14.2",
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.9",
"@angular/cli": "~17.0.9",
"@angular/compiler-cli": "^17.0.8",
"@aws-sdk/client-acm": "^3.485.0",
"@aws-sdk/client-appsync": "^3.485.0",
"@aws-sdk/client-cognito-identity": "^3.485.0",
"@aws-sdk/client-cognito-identity-provider": "^3.485.0",
"@aws-sdk/credential-provider-ini": "^3.485.0",
"@types/jasmine": "~5.1.0",
"@types/node": "18.0.6",
"@types/uuid": "^9.0.7",
"aws-cdk": "^2.118.0",
"aws-cdk-lib": "^2.118.0",
"aws-sdk": "^2.1531.0",
"constructs": "^10.3.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.2.2"
}
}
and this is from the root package in the mono repo:
{
"name": "@apollo/source",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"build": "nx run-many --target build",
"deploy": "nx run-many --target deploy",
"aws-config": "npx ts-node --project tsconfig.aws.json libs/config/aws-config.ts",
"aws-config2": "npx ts-node --project tsconfig.aws.json libs/config/aws-config2.ts",
"install": "nx run-many --target install",
"bootstrap": "nx run-many --target bootstrap",
"migrate": "nx run-many --target migrate",
"build:affected": "nx affected --target build --base=origin/master~1",
"deploy:affected": "nx affected --target deploy --base=origin/master~1",
"reset": "nx reset",
"docs": "nx start --project docs",
"cy:verify": "nx cy:verify --project testing",
"cy:info": "nx cy:info --project testing",
"cy:install": "nx cy:install --project testing",
"test:cypress:staging:run": "nx test:cypress:staging:run --project testing",
"test:cypress:smoke:run": "nx test:cypress:smoke:run --project testing",
"test:cypress:report:smoke": "nx test:cypress:report:smoke --project testing",
"client-api:build": "nx build --project @apollo/client-api",
"client-api:deploy": "nx deploy --project @apollo/client-api"
},
"private": true,
"dependencies": {},
"devDependencies": {
"@nx/js": "16.9.0",
"@nx/workspace": "16.9.0",
"nx": "16.9.0",
"prettier": "^2.6.2",
"typescript": "~5.1.3",
"@aws-sdk/client-cognito-identity": "^3.485.0",
"@aws-sdk/client-cognito-identity-provider": "^3.485.0",
"@aws-sdk/client-acm": "^3.485.0",
"@aws-sdk/client-appsync": "^3.485.0",
"@aws-sdk/credential-provider-ini": "^3.485.0",
"@aws-sdk/client-kms": "^3.485.0",
"@aws-sdk/client-dynamodb": "^3.485.0",
"ts-node": "^10.9.1",
"eslint": "^8.44.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"aws-cdk-lib": "2.118.0",
"constructs": "^10.3.0",
"aws-amplify": "^6.0.17"
}
}
I have removed all amplify 5.4 dependencies and all node_modules everywhere and run pnpn i
again.
Then I run a build and I get
../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@aws-amplify/api/dist/esm/index.mjs:4:0-61 - Error: Module not found: Error: Can't resolve '@aws-amplify/core/internals/utils' in '/Users/mattijs/www/respark/apollo/apollo/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@aws-amplify/api/dist/esm'
So weird.
Okay, I got some more information: I just upgrade amplify 5.4 to 6 in an old A17 project from the pre mono repo period, using NPM instead of PNPM, and I am not getting any errors. So it is 100% related to pnpm.
Is there any way I can work around this? Because stepping away from the mono repo is not an option .
@israx do you have an update on this?
hello @mattiLeBlanc . So sorry for the delay. I'll communicate this today with the team and give you an update. Sorry again for the waiting
No problem. Thank you trying to help me out.
On Tue, 5 Mar 2024 at 21:40, israx @.***> wrote:
hello @mattiLeBlanc https://github.com/mattiLeBlanc . So sorry for the delay. I'll communicate this today with the team and give you an update. Sorry again for the waiting
— Reply to this email directly, view it on GitHub https://github.com/aws-amplify/amplify-js/issues/13054#issuecomment-1978799525, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIKJK6CPHEBDEHTTSFZX3LYWXDM5AVCNFSM6AAAAABD3RY3QCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZYG44TSNJSGU . You are receiving this because you were mentioned.Message ID: @.***>
@mattiLeBlanc, could you share how you're configuring Amplify as well? Any frontend code where Amplify.configure()
is being called as well as what your config looks like (with sensitive data redacted as needed) might be helpful for determining what's going on here.
Can you share package.json
files you have on each package on the monorepo?
@cwomack I have added the relevant files to a zip archive if you are comfortable with it.
This the content:
I have removed sensitive config from aws. I only use amplify in the main.ts, the auth.service.ts and the api.service.ts.
Can you share
package.json
files you have on each package on the monorepo?
In addition to the files I shared above for the root and admin, this is for the family angular app:
{
"name": "@apollo/family-app",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host apollo-family-app --port 4202 --open",
"build": "./../../scripts/build-angular.sh",
"build-dev": "ng build --configuration development",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"createVersionFile": "node create-version.js",
"extract-translations": "ngx-translate-extract --input ./src --output ./src/assets/i18n/en.json --sort --format namespaced-json --marker _",
"deploy": "cdk deploy --require-approval never",
"cdk": "cdk"
},
"private": true,
"dependencies": {
"@angular/animations": "^17.0.8",
"@angular/cdk": "^17.0.4",
"@angular/common": "^17.0.8",
"@angular/compiler": "^17.0.8",
"@angular/core": "^17.0.8",
"@angular/forms": "^17.0.8",
"@angular/material": "^17.0.4",
"@angular/platform-browser": "^17.0.8",
"@angular/platform-browser-dynamic": "^17.0.8",
"@angular/router": "^17.0.8",
"angular-google-tag-manager": "^1.9.0",
"aws-amplify": "^6.0.17",
"material-icons": "^1.13.12",
"rxjs": "~7.8.0",
"dayjs": "^1.11.7",
"svg-inline-loader": "^0.8.2",
"tslib": "^2.3.0",
"zone.js": "~0.14.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.9",
"@angular/cli": "~17.0.9",
"@angular/compiler-cli": "^17.0.8",
"@aws-sdk/client-acm": "^3.485.0",
"@aws-sdk/client-appsync": "^3.485.0",
"@aws-sdk/client-cognito-identity": "^3.485.0",
"@aws-sdk/client-cognito-identity-provider": "^3.485.0",
"@types/jasmine": "~4.3.0",
"@types/node": "18.0.6",
"autoprefixer": "^10.4.16",
"aws-cdk": "^2.118.0",
"aws-cdk-lib": "^2.118.0",
"constructs": "^10.3.0",
"jasmine-core": "~4.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"postcss": "^8.4.30",
"tailwindcss": "^3.3.3",
"typescript": "~5.2.2"
}
}
and this is for the client app:
{
"name": "@apollo/apollo-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host apollo-app --port 4201 --open --configuration development",
"build": "./../../scripts/build-angular.sh",
"build-dev": "ng build --configuration development",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"createVersionFile": "node create-version.js",
"extract-translations": "ngx-translate-extract --input ./src --output ./src/assets/i18n/en.json --sort --format namespaced-json --marker _",
"deploy": "cdk deploy --require-approval never",
"cdk": "cdk"
},
"private": true,
"dependencies": {
"@angular/animations": "^17.0.8",
"@angular/cdk": "^17.0.4",
"@angular/common": "^17.0.8",
"@angular/compiler": "^17.0.8",
"@angular/core": "^17.0.8",
"@angular/forms": "^17.0.8",
"@angular/material": "^17.0.4",
"@angular/platform-browser": "^17.0.8",
"@angular/platform-browser-dynamic": "^17.0.8",
"@angular/router": "^17.0.8",
"@angular/youtube-player": "^17.0.4",
"@iplab/ngx-file-upload": "^17.0.0",
"@vimeo/player": "^2.18.0",
"angular-google-tag-manager": "^1.9.0",
"aws-amplify": "^6.0.17",
"axios": "^1.3.4",
"dayjs": "^1.11.7",
"material-icons": "^1.13.12",
"nosleep.js": "^0.12.0",
"rxjs": "~7.8.0",
"svg-inline-loader": "^0.8.2",
"tailwindcss": "^3.3.3",
"tslib": "^2.3.0",
"zone.js": "~0.14.2",
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.9",
"@angular/cli": "~17.0.9",
"@angular/compiler-cli": "^17.0.8",
"@aws-amplify/api": "^5.4.7",
"@aws-amplify/pubsub": "^5.5.7",
"@aws-sdk/client-acm": "^3.379.1",
"@aws-sdk/client-appsync": "^3.379.1",
"@aws-sdk/client-cognito-identity": "^3.379.1",
"@aws-sdk/client-cognito-identity-provider": "^3.379.1",
"@aws-sdk/credential-provider-ini": "^3.379.1",
"@types/jasmine": "~4.3.0",
"@types/node": "18.0.6",
"@types/prettier": "2.6.0",
"@types/vimeo__player": "^2.16.3",
"@types/youtube": "^0.0.47",
"aws-cdk": "^2.118.0",
"aws-cdk-lib": "^2.118.0",
"aws-sdk": "^2.1531.0",
"constructs": "^10.3.0",
"jasmine-core": "~4.5.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "~5.2.2"
}
}
And just to reiterate : when I install amplify in a separate angular project using npm only, it works fine. With pnpm I am experiencing this issue only.
@nadetastic Any luck reproducing the error?
@israx hey, is it possible to have a look at this? It is blocking me from upgrading to Amplify v6 in our production app and I would like to finish that piece.
@mattiLeBlanc im not sure exactly how pnpm would be play a role with this issue, ive been able to get aws-amplify@6
working with a stand alone application using pnpm as well as a pnpm workspace/monorepo without issues. Looking at the root package.json you shared in the zip, I see references to nx
so its possible that this is where the issue lies.
Would it be possible to further share a sample of your monorepo setup thats similar to what you have? What you shared seems to just be specific files without any structure.
@nadetastic I agree, the standalone works okay. I referred to pnpm because of the error
../../node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@aws-amplify/api/dist/esm/index.mjs:4:25:
4 │ export { ApiError } from '@aws-amplify/core/internals/utils';
mentioning node_modules/.pnpm/@aws-amplify
in the path but that may be irrelevant.
I am not a mono repo expert right now, but I thought NX is just taking care of building projects in its structure but not involved with dependencies.
Is there a workaround where I specifically mention @aws-amplify/core/internals/utils
because now that I remember it, NX seems to have issues with peer dependencies that are not specified in the main package files.
Maybe I can add this library specifically to the package file?
Hello,
I have the same error for RN project. (after migration from v5 to V6)
The package.json file :
"dependencies": { "@aws-amplify/core": "5.1.13", "@aws-amplify/react-native": "^1.0.20", "@react-native-async-storage/async-storage": "^1.22.3", "@react-native-camera-roll/camera-roll": "^7.2.2", "@react-native-community/datetimepicker": "7.0.0", "@react-native-community/netinfo": "^11.3.1", "@react-native-firebase/app": "18.8.0", "@react-native-firebase/crashlytics": "18.8.0", "@react-native-firebase/messaging": "18.8.0", "@react-navigation/bottom-tabs": "6.5.7", "@react-navigation/core": "6.4.8", "@react-navigation/native": "6.1.6", "@react-navigation/stack": "^6.3.20", "aws-amplify": "^6.0.20", "date-fns": "2.29.3", "formik": "2.2.9", "i18next": "22.4.13", "patch-package": "^8.0.0", "react": "18.2.0", "react-i18next": "12.2.0", "react-native": "0.73.2", "react-native-blob-util": "0.19.4", "react-native-config": "1.4.12", "react-native-device-info": "^10.11.0", "react-native-fast-image": "8.6.3", "react-native-gesture-handler": "^2.14.1", "react-native-get-random-values": "^1.11.0", "react-native-linear-gradient": "^2.8.3", "react-native-localize": "2.2.6", "react-native-modal": "13.0.1", "react-native-permissions": "3.7.3", "react-native-safe-area-context": "4.5.0", "react-native-screens": "3.29.0", "react-native-splash-screen": "3.3.0", "react-native-svg": "13.8.0", "react-native-svg-transformer": "1.3.0", "react-native-video": "5.2.1", "react-redux": "8.0.5", "redux": "4.2.1", "redux-persist": "6.0.0", "redux-saga": "1.2.3", "reselect": "4.1.7", "yup": "0.32.11" },
Any idea what could be wrong here?
Thanks,;
EDIT : Got it, the "aws-amplify/core" dependency was generating the issue.
@AntonyARHS can you elaborate further how the core was generating the issue? How did you resolve it?
@AntonyARHS can you elaborate further how the core was generating the issue? How did you resolve it?
@mattiLeBlanc I just removed the aws-amplify/core dependency from my package.json file and the issue disappears and everything work as expected.
@AntonyARHS Oh, okay. I am not having that dependency, just aws-amplify
so it won't make any difference from me.
I am actually setting up a new mono repo with pnpm, just NX and npm and see how that goes.
@mattiLeBlanc, have you had a chance to test the new mono repo with pnpm
to see if the error is still being produced?
Hi Chris, I upgraded to pnpm 9 and I still get the same error :
../../node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/api/dist/esm/index.mjs:4:0-61 - Error: Module not found: Error: Can't resolve '@aws-amplify/core/internals/utils' in '/Users/mattijs/www/respark/apollo/apollo/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/api/dist/esm'
I am working on a side branch to get rid of pnpm but I am in a production build process right now and have limited time. The NX project without pnpm did not have any issue so far.