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

Error: Unable to resolve module @aws-sdk/chunked-blob-reader #11166

Closed woliwa1 closed 1 year ago

woliwa1 commented 1 year ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

REST API, Push Notifications, PubSub

Amplify Categories

No response

Environment information

``` # Put output below this line Unable to resolve module @aws-sdk/chunked-blob-reader from /Users/xxx/xxx/name/react-native/node_modules/@aws-sdk/hash-blob-browser/dist-cjs/index.js: @aws-sdk/chunked-blob-reader could not be found within the project or in these directories: node_modules 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.blobHasher = void 0; > 4 | const chunked_blob_reader_1 = require("@aws-sdk/chunked-blob-reader"); | ^ 5 | const blobHasher = async function blobHasher(hashCtor, blob) { 6 | const hash = new hashCtor(); 7 | await (0, chunked_blob_reader_1.blobReader)(blob, (chunk) => { ```

Describe the bug

"@aws-sdk/client-cognito-identity": "^3.178.0",
"@aws-sdk/client-s3": "^3.171.0",
"@aws-sdk/credential-provider-cognito-identity": "^3.171.0",
"@aws-sdk/fetch-http-handler": "^3.186.0",
"@aws-sdk/middleware-endpoint": "^3.178.0",
"@aws-sdk/protocol-http": "^3.186.0",
"@aws-sdk/querystring-builder": "^3.186.0",
"@aws-sdk/s3-request-presigner": "^3.173.0",
"aws-sdk": "^2.1212.0",

 Unable to resolve module @aws-sdk/chunked-blob-reader from /Users/xxx/xxx/name/react-
 native/node_modules/@aws-sdk/hash-blob-browser/dist-cjs/index.js: @aws-sdk/chunked-blob-reader 
 could not be found within the project or in these directories:
 node_modules
 2 | Object.defineProperty(exports, "__esModule", { value: true });
 3 | exports.blobHasher = void 0;

4 | const chunked_blob_reader_1 = require("@aws-sdk/chunked-blob-reader"); | ^ 5 | const blobHasher = async function blobHasher(hashCtor, blob) { 6 | const hash = new hashCtor(); 7 | await (0, chunked_blob_reader_1.blobReader)(blob, (chunk) => {

rm -rf node_modules rm -rf Pods rm -rf ${TMPDIR:-/tmp}/metro-* yarn start --reset-cache have no effect

System: OS: macOS 13.2.1 CPU: (10) arm64 Apple M1 Pro Memory: 111.31 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.14.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.3.1 - /usr/local/bin/npm Watchman: 2023.02.27.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 111.0.5563.146 Safari: 16.3 npmGlobalPackages: corepack: 0.15.3 n: 9.0.1 npm: 9.3.1 nrm: 1.2.5 open: 8.4.2 react-native-cli: 2.0.1 yarn: 1.22.19

Expected behavior

Simulator normal operation

Reproduction steps

rm -rf node_modules package-lock.json npm install

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

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

nadetastic commented 1 year ago

Hi @woliwa1 looks like the first steps to reproduce this is to remove the node_modules folder and package-lock.json file, then run npm install.

Could you share what the package.json file looks like?

woliwa1 commented 1 year ago

{ "name": "demo", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios --simulator='iPhone 14 Pro Max'", "start": "react-native start", "test": "jest", "android-bundle": "npx mkdirp android/app/src/main/assets && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release", "android-bundle-release": "cd android && ./gradlew bundleRelease", "android-release": "npm run-script android-bundle && npm run-script android-bundle-release && open android/app/build/outputs/bundle/release", "postinstall": "patch-package" }, "dependencies": { "@aws-sdk/client-cognito-identity": "^3.178.0", "@aws-sdk/client-s3": "^3.171.0", "@aws-sdk/credential-provider-cognito-identity": "^3.171.0", "@aws-sdk/fetch-http-handler": "^3.186.0", "@aws-sdk/middleware-endpoint": "^3.178.0", "@aws-sdk/protocol-http": "^3.186.0", "@aws-sdk/querystring-builder": "^3.186.0", "@aws-sdk/s3-request-presigner": "^3.173.0", "@invertase/react-native-apple-authentication": "^2.2.2", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-clipboard/clipboard": "^1.11.0", "@react-native-community/blur": "^4.2.0", "@react-native-community/netinfo": "^9.3.7", "@react-native-firebase/app": "^17.3.0", "@react-native-firebase/auth": "^17.3.0", "@react-native-firebase/messaging": "^17.3.0", "@react-native-google-signin/google-signin": "^9.0.2", "@react-native-masked-view/masked-view": "^0.2.8", "@react-native-seoul/masonry-list": "^1.3.3", "@react-navigation/bottom-tabs": "^6.3.2", "@react-navigation/material-top-tabs": "^6.2.3", "@react-navigation/native": "^6.0.11", "@react-navigation/native-stack": "^6.7.0", "@reduxjs/toolkit": "^1.8.5", "@segment/analytics-react-native": "^2.8.0", "@segment/sovran-react-native": "^0.4.4", "aws-sdk": "^2.1212.0", "axios": "^0.27.2", "base64-arraybuffer": "^1.0.2", "install": "^0.13.0", "lottie-ios": "3.4.0", "lottie-react-native": "^5.1.4", "metro-config": "^0.72.2", "patch-package": "^6.5.1", "prop-types": "^15.8.1", "react": "18.0.0", "react-native": "0.69.4", "react-native-actions-sheet": "^0.8.29", "react-native-animated-loader": "^1.0.0", "react-native-collapsible": "^1.6.0", "react-native-config": "^1.5.0", "react-native-device-info": "^10.2.1", "react-native-element-dropdown": "^2.3.0", "react-native-encrypted-storage": "^4.0.3", "react-native-fast-image": "^8.6.3", "react-native-fbsdk-next": "^10.1.0", "react-native-fs": "^2.20.0", "react-native-geolocation-service": "^5.3.0", "react-native-gesture-handler": "^2.6.0", "react-native-get-random-values": "^1.8.0", "react-native-google-places-autocomplete": "^2.4.1", "react-native-haptic-feedback": "^1.14.0", "react-native-image-crop-picker": "^0.38.0", "react-native-image-picker": "^4.10.0", "react-native-keyboard-accessory": "^0.1.16", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.6.2", "react-native-localize": "^2.2.4", "react-native-modal": "^13.0.1", "react-native-otp-inputs": "^7.4.0", "react-native-pager-view": "^6.0.0", "react-native-render-html": "^6.3.4", "react-native-safe-area-context": "^4.3.3", "react-native-screens": "^3.17.0", "react-native-share": "^7.9.0", "react-native-size-matters": "^0.4.0", "react-native-splash-screen": "^3.3.0", "react-native-svg": "^12.4.4", "react-native-swiper-flatlist": "^3.0.18", "react-native-tab-view": "^3.5.1", "react-native-toast-notifications": "^3.3.1", "react-native-url-polyfill": "^1.3.0", "react-native-uuid": "^2.0.1", "react-native-video": "^6.0.0-alpha.1", "react-native-walkthrough-tooltip": "^1.4.0", "react-redux": "^8.0.2", "realm": "^10.20.0", "redux": "^4.2.0", "rxjs": "^7.5.7", "slate": "^0.91.4", "uuid": "^9.0.0" }, "devDependencies": { "@babel/core": "^7.18.10", "@babel/runtime": "^7.18.9", "babel-jest": "^28.1.3", "eslint": "^8.22.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.6.1", "eslint-plugin-react": "^7.30.1", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-native": "^4.0.0", "jest": "^28.1.3", "metro-react-native-babel-preset": "^0.72.2", "prettier": "2.7.1", "react-native-svg-transformer": "^1.0.0", "react-test-renderer": "18.0.0" }, "jest": { "preset": "react-native" } } @nadetastic It would be great if you could help me find the problem

woliwa1 commented 1 year ago

Found the reason, this is caused by package-lock.json.

nadetastic commented 1 year ago

@woliwa1 glad you were able to get this working.

Elisebassett commented 1 year ago

@woliwa1 what exactly was the problem? I'm having the same issue, but I've removed my node_modules folder, my yarn.lock (i don't have a package-lock.json) and run yarn, and I'm still seeing the same issues. What about your package-lock.json was causing the issue, and what did you do to fix it?