react-native-gifted-chat\node_modules\expo\AppEntry.js not found

Created on 12 Jun 2019  路  16Comments  路  Source: FaridSafi/react-native-gifted-chat

Issue Description

When intsalling the last version of gifted chat (0.9.*) i have an error at metro launch.
Herer is the error :

error: bundling failed: Error: While trying to resolve module react-native-gift ed-chat from file C:\Users\nount\WebstormProjects\daate\src\screens\user\showP rofile4.js, the package C:\Users\nount\WebstormProjects\daate\node_modules\rea ct-native-gifted-chat\package.json was successfully found. However, this packag e itself specifies a main module field that could not be resolved (C:\Users\n ount\WebstormProjects\daate\node_modules\react-native-gifted-chat\node_modules\e xpo\AppEntry.js. Indeed, none of these files exist:

  • C:\Users\nount\WebstormProjects\daate\node_modules\react-native-gifted-chat \node_modules\expo\AppEntry.js(.native||.android.js|.native.js|.js|.android.json |.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  • C:\Users\nount\WebstormProjects\daate\node_modules\react-native-gifted-chat \node_modules\expo\AppEntry.js\index(.native||.android.js|.native.js|.js|.androi d.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.t sx)
    at ResolutionRequest.resolveDependency (C:\Users\nount\WebstormProjects\daat e\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:65:15)
    at DependencyGraph.resolveDependency (C:\Users\nount\WebstormProjects\daate\ node_modules\metro\src\node-haste\DependencyGraph.js:283:16)
    at Object.resolve (C:\Users\nount\WebstormProjects\daate\node_modules\metro\ src\lib\transformHelpers.js:261:42)
    at dependencies.map.result (C:\Users\nount\WebstormProjects\daate\node_modul es\metro\src\DeltaBundler\traverseDependencies.js:399:31)
    at Array.map ()
    at resolveDependencies (C:\Users\nount\WebstormProjects\daate\node_modules\m etro\src\DeltaBundler\traverseDependencies.js:396:18)
    at C:\Users\nount\WebstormProjects\daate\node_modules\metro\src\DeltaBundler \traverseDependencies.js:269:33
    at Generator.next ()
    at asyncGeneratorStep (C:\Users\nount\WebstormProjects\daate\node_modules\me tro\src\DeltaBundler\traverseDependencies.js:87:24)
    at _next (C:\Users\nount\WebstormProjects\daate\node_modules\metro\src\Delta Bundler\traverseDependencies.js:107:9)
    ::1 - - [12/Jun/2019:12:19:02 +0000] "GET /index.delta?platform=android&dev=true &minify=false&revisionId=ac05c803b916d881 HTTP/1.1" 500 - "http://localhost:8081 /debugger-ui/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KH TML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
    DELTA [android, dev] ./index.js 鈻撯枔鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒 18.5% (186/518), failed.

::1 - - [12/Jun/2019:12:20:35 +0000] "GET /index.delta?platform=android&dev=true &minify=false HTTP/1.1" 500 - "http://localhost:8081/debugger-ui/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0 .3729.169 Safari/537.36"
error: bundling failed: Error: While trying to resolve module react-native-gift ed-chat from file C:\Users\nount\WebstormProjects\daate\src\screens\user\showP rofile4.js, the package C:\Users\nount\WebstormProjects\daate\node_modules\rea ct-native-gifted-chat\package.json was successfully found. However, this packag e itself specifies a main module field that could not be resolved (C:\Users\n ount\WebstormProjects\daate\node_modules\react-native-gifted-chat\node_modules\e xpo\AppEntry.js. Indeed, none of these files exist:

  • C:\Users\nount\WebstormProjects\daate\node_modules\react-native-gifted-chat \node_modules\expo\AppEntry.js(.native||.android.js|.native.js|.js|.android.json |.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
  • C:\Users\nount\WebstormProjects\daate\node_modules\react-native-gifted-chat \node_modules\expo\AppEntry.js\index(.native||.android.js|.native.js|.js|.androi d.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.t sx)
    at ResolutionRequest.resolveDependency (C:\Users\nount\WebstormProjects\daat e\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:65:15)
    at DependencyGraph.resolveDependency (C:\Users\nount\WebstormProjects\daate\ node_modules\metro\src\node-haste\DependencyGraph.js:283:16)
    at Object.resolve (C:\Users\nount\WebstormProjects\daate\node_modules\metro\ src\lib\transformHelpers.js:261:42)
    at dependencies.map.result (C:\Users\nount\WebstormProjects\daate\node_modul es\metro\src\DeltaBundler\traverseDependencies.js:399:31)
    at Array.map ()
    at resolveDependencies (C:\Users\nount\WebstormProjects\daate\node_modules\m etro\src\DeltaBundler\traverseDependencies.js:396:18)
    at C:\Users\nount\WebstormProjects\daate\node_modules\metro\src\DeltaBundler \traverseDependencies.js:269:33
    at Generator.next ()
    at asyncGeneratorStep (C:\Users\nount\WebstormProjects\daate\node_modules\me tro\src\DeltaBundler\traverseDependencies.js:87:24)
    at _next (C:\Users\nount\WebstormProjects\daate\node_modules\metro\src\Delta Bundler\traverseDependencies.js:107:9)
    DELTA [android, dev] ./index.js 鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒 0.0% (0/1), failed.

Steps to Reproduce / Code Snippets

Install the last version of gifted chat (0.9.*), then try to launch your app

Expected Results

Have gifted chat working

Additional Information

  • Nodejs version: 10.16.0
  • React version: 16.8.3
  • React Native version: 0.59.8
  • react-native-gifted-chat version: 0.9.3
  • Platform(s) (iOS, Android, or both?): Both

Most helpful comment

I have no idea why this has been closed, or it's perceived as not being related related to this library.

@tmjordan, I've also faced the same issue, it appears like the contents of the published version of gifted-chat is different than the version you fork, and this is because npm runs a prepublishing process (https://docs.npmjs.com/misc/scripts) before actually publishing it, I've been managed to get my fork to work this way:
On my main application, I've added the following postinstall script:

"scripts": { "postinstall": "cd node_modules/react-native-gifted-chat && yarn install && yarn lint && yarn build && yarn config:npm && rm -rf node_modules" },

All 16 comments

Oups !
Did you test the 0.9.4 also?

How do you install Gifted chat?
Please paste your dependency declaration. Because if you are using master it's normal, ie. github dependency.

Can you please paste the node_modules/react-native-gifted-chat/package.json?
Thank you

Hi @xcarpentier thanks for the reply. I'm using the last version of gifted chat (0.9.5). I made a fork of the repo in order to remove the react-native-video from the dependencies. There is no other change and it is not related to my problem.
Here is the package.json file:

{
  "_from": "github:tm-jordan/react-native-gifted-chat",
  "_id": "[email protected]",
  "_inBundle": false,
  "_integrity": "",
  "_location": "/react-native-gifted-chat",
  "_phantomChildren": {
    "babel-plugin-check-es2015-constants": "6.22.0",
    "prop-types": "15.6.2"
  },
  "_requested": {
    "type": "git",
    "raw": "react-native-gifted-chat@github:tm-jordan/react-native-gifted-chat",
    "name": "react-native-gifted-chat",
    "escapedName": "react-native-gifted-chat",
    "rawSpec": "github:tm-jordan/react-native-gifted-chat",
    "saveSpec": "github:tm-jordan/react-native-gifted-chat",
    "fetchSpec": null,
    "gitCommittish": null
  },
  "_requiredBy": [
    "/"
  ],
  "_resolved": "github:tm-jordan/react-native-gifted-chat#fbed5710380aae4a00134e5fb5686fd0f93feca6",
  "_spec": "react-native-gifted-chat@github:tm-jordan/react-native-gifted-chat",
  "_where": "C:\\Users\\nount\\WebstormProjects\\daate_v1.1.0\\daate",
  "author": {
    "name": "Farid Safi"
  },
  "bugs": {
    "url": "https://github.com/FaridSafi/react-native-gifted-chat/issues"
  },
  "bundleDependencies": false,
  "dependencies": {
    "@expo/react-native-action-sheet": "^2.0.1",
    "expo-constants": "~5.0.1",
    "expo-image-picker": "~5.0.2",
    "expo-location": "~5.0.1",
    "expo-permissions": "~5.0.1",
    "moment": "^2.19.0",
    "react-native-communications": "2.2.1",
    "react-native-iphone-x-helper": "^1.2.0",
    "react-native-lightbox": "^0.7.0",
    "react-native-maps": "~0.24.0",
    "react-native-parsed-text": "^0.0.20",
    "tslib": "^1.9.3",
    "uuid": "3.3.0"
  },
  "deprecated": false,
  "description": "The most complete chat UI for React Native",
  "devDependencies": {
    "@babel/core": "^7.1.2",
    "@babel/preset-typescript": "^7.1.0",
    "@types/jest": "24.0.14",
    "@types/react": "^16.7.17",
    "@types/react-native": "^0.57.19",
    "@types/react-native-communications": "2.2.1",
    "@types/react-native-video": "3.1.4",
    "@types/react-test-renderer": "16.8.2",
    "@types/uuid": "3.4.4",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "24.7.1",
    "babel-preset-expo": "^5.0.0",
    "expo": "^33.0.0",
    "husky": "^2.4.0",
    "jest-expo": "^33.0.0",
    "json": "^9.0.6",
    "prettier": "1.18.0",
    "prop-types": "15.6.2",
    "react": "16.5.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
    "react-native-nav": "2.0.2",
    "react-test-renderer": "16.5.1",
    "tslint": "5.12.0",
    "tslint-config-prettier": "1.17.0",
    "typescript": "3.4.5"
  },
  "homepage": "https://github.com/FaridSafi/react-native-gifted-chat#readme",
  "husky": {
    "hooks": {
      "pre-commit": "yarn lint && yarn tsc"
    }
  },
  "jest": {
    "preset": "react-native",
    "setupFiles": [
      "./tests/setup.js"
    ],
    "moduleFileExtensions": [
      "js",
      "jsx",
      "json",
      "ts",
      "tsx"
    ],
    "transform": {
      "^.+\\.(js|jsx|ts|tsx)$": "babel-jest"
    },
    "testMatch": [
      "**/*.test.ts?(x)"
    ],
    "modulePathIgnorePatterns": [
      "<rootDir>/example",
      "<rootDir>/example-expo",
      "<rootDir>/example-slack-message"
    ]
  },
  "keywords": [
    "android",
    "ios",
    "react-native",
    "react",
    "react-component",
    "messenger",
    "message",
    "chat"
  ],
  "license": "MIT",
  "main": "node_modules/expo/AppEntry.js",
  "name": "react-native-gifted-chat",
  "peerDependencies": {
    "prop-types": "*",
    "react": "*",
    "react-native": "*",
    "react-native-video": "*"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/FaridSafi/react-native-gifted-chat.git"
  },
  "scripts": {
    "build": "rm -rf lib/ && node_modules/.bin/tsc",
    "config:dev": "json -I -f package.json -e 'this.main=\"node_modules/expo/AppEntry.js\"'",
    "config:npm": "json -I -f package.json -e 'this.main=\"lib/index.js\"'",
    "lint": "tslint --project .",
    "postpublish": "yarn config:dev",
    "prepublishOnly": "yarn lint && yarn build && yarn test && yarn config:npm",
    "test": "TZ=Europe/Paris jest --no-watchman",
    "test:coverage": "TZ=Europe/Paris jest --coverage",
    "test:watch": "TZ=Europe/Paris jest --watch",
    "tsc": "tsc --noEmit"
  },
  "types": "lib/index.d.ts",
  "version": "0.9.5"
}

@xcarpentier when i look into the node_modules folder of the installed gifted-chat, i notice that there is no expo folder, so gifted-chat can't find "node_modules/expo/AppEntry.js"
I don't know why it is not installed

I install gifted chat by using npm
npm install --save react-native-gifted-chat
Yes i try the latest versions at the moment (0.9.4 & 0.9.5). Same results
That error started to occur since version 0.8.0 of gifted-chat
So for now i'm stuck to the version 0.7.3, which is the last version working for me

I guess this is because you are not using the npm version after application of scripts on publish.

As you can read script on npm publish I change the package.json > main

  • prepublishOnly
  • postpublish

So can't use it as a github dependency you have to use npm one.

or if you want to use it from your fork you have to set main to "lib/index.js"

@xcarpentier i dont't really understand what i should do. Upgrade npm to the last version ??

what should i do, if i don't want to use my fork ?

Sorry, but I think you have to figure out by yourself.
You have to use it like it is, version 0.9.5 that should work...
If not, I think there is an issue using it with JS, I'm using it as TS app right now without any issue, I don't think JS has issues but maybe...

@xcarpentier I tried using "lib/index.js", but now the error points to "lib/index.js" not found.
I think i have some missing files but i don't understand why. None of these files exist in the node_modules folder of gifted_chat.
I will try with TS in a new project, or try install by using yarn instead of npm.
Anyway thanks for your help, for now i will stay with 0.7.3 version of gifted-chat.

I have no idea why this has been closed, or it's perceived as not being related related to this library.

@tmjordan, I've also faced the same issue, it appears like the contents of the published version of gifted-chat is different than the version you fork, and this is because npm runs a prepublishing process (https://docs.npmjs.com/misc/scripts) before actually publishing it, I've been managed to get my fork to work this way:
On my main application, I've added the following postinstall script:

"scripts": { "postinstall": "cd node_modules/react-native-gifted-chat && yarn install && yarn lint && yarn build && yarn config:npm && rm -rf node_modules" },

@nadav2051 you are right, like I said here: https://github.com/FaridSafi/react-native-gifted-chat/issues/1265#issuecomment-501686302

You can't use a fork and use directly from github because on npm publish npm scripts change the main file.

You're right, I somehow missed that comment, had to learn the hard way :)

yarn build is failing because of warning/erros while compiling with tsc. How do you make sure, build is successful ? I am not using typescript in my project. I am trying to use my own fork.
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emilkarl picture emilkarl  路  3Comments

Hayko1994 picture Hayko1994  路  3Comments

tafelito picture tafelito  路  3Comments

SytzeAndr picture SytzeAndr  路  3Comments

luisar picture luisar  路  3Comments