Giftedchat moment.js problem

Hello,

after upgrade to sdk22, I got the error about giftetchat below;

“require() must have a single string literal argument”

is there anyone to solve that problem.

It appears that moment.js uses a dynamic require and this is causing problems for react native. You can read more on that here.

Here is the moment.js PR to fix this.

By the way, we recommend following the breaking changes in the release notes, where this issue is mentioned and a solution is linked to: Expo SDK v22.0.0 is now available | by Brent Vatne | Exposition

Hello,

I upgraded to expo 24 sdk and i have moment installed. I got this same error? Is this still moment issue or a different module at this point? I also installed Reactron but I don’t think this would be an issue at this point

{
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "scripts": {
    "test": "node ./node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/samples": "2.1.1",
    "@expo/vector-icons": "^6.2.2",
    "axios": "^0.17.1",
    "expo": "^24.0.0",
    "firebase": "^4.8.1",
    "libphonenumber-js": "^0.4.48",
    "lodash": "^4.17.4",
    "moment": "^2.20.1",
    "qs": "^6.5.1",
    "react": "16.0.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-24.0.0.tar.gz",
    "react-native-elements": "^0.18.5",
    "react-native-image-gallery": "^2.1.4",
    "react-native-modalbox": "^1.4.2",
    "react-navigation": "^1.0.0-beta.22",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-persist": "^5.4.0",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-eslint": "^7.2.3",
    "eslint": "^4.14.0",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-plugin-import": "^2.8.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.5.1",
    "jest-expo": "^23.0.1",
    "reactotron-react-native": "^1.14.0",
    "reactotron-redux": "^1.13.0"
  },
  "resolutions": {
    "moment": "2.20.1"
  }
}

by the way the error is the same TransformError: require() must have a single string literal argument

you should update to the latest version of moment :slight_smile:

2 Likes