Error: jest-haste-map: Haste module naming collision: Duplicate module name: react-native khi update Expo từ v27 lên v33

Thực ra mình muốn lên hẳn V44 luôn bằng lệnh expo update 44.0.0 nhưng expo cảnh báo chỉ nên chạy khi đang ở v33 trở lên nên đành phải update từ 27 lên 33 trước theo hướng dẫn:

// Đổi các dòng tương ứng trong packages.json

{
  "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
  "expo": "^33.0.0",
  "react": "16.8.3"
}

Update xong chạy thì gặp lỗi:

C:\Users\Hao\Documents\GitHub\eaglemobile\node_modules\metro\node_modules\jest-haste-map\build\index.js:569
          throw new Error(message);
                ^

Error: jest-haste-map: Haste module naming collision:
  Duplicate module name: react-native
  Paths: C:\Users\Hao\Documents\GitHub\eaglemobile\node_modules\expo\node_modules\react-native\package.json collides with C:\Users\Hao\Documents\GitHub\eaglemobile\node_modules\react-native\package.json

This error is caused by `hasteImpl` returning the same name for different files.
    at setModule (C:\Users\Hao\Documents\GitHub\eaglemobile\node_modules\metro\node_modules\jest-haste-map\build\index.js:569:17)
    at workerReply (C:\Users\Hao\Documents\GitHub\eaglemobile\node_modules\metro\node_modules\jest-haste-map\build\index.js:641:9)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 13569)

Search 1 lúc thì ra hướng dẫn sau xài được.

Tạo file rn-cli.config.js để ở thư mục gốc của project với nội dung sau:

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
    resolver: {
        blacklistRE: blacklist([
            /node_modules\/.*\/node_modules\/react-native\/.*/,
        ])
    },
};

Done

Leave a Reply

Your email address will not be published. Required fields are marked *