I am working on
react-native 0.75.2
yarn 3.6.4
node 20
In my project, I have a native module dependency, which is located inside my project folder. My package.json
looks like
"dependencies": {
....,
"react-native-my-native-mod": "file:native_modules/react-native-my-native-mod",
}
In gitlab-runner
, it is creating an error because in gitlab-ci.yml
, I have script like
yarn install --immutable
The error is "The lockfile would have been modified by this install, which is explicitly forbidden."
and it shows checksum
difference in my native module.
I am using .yarnrc.yml
that looks like
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.6.4.cjs
I guess, when the project is locally installed by yarn install, the module is installed from the location I have specified in package.json
i.e. file:native_modules/react-native-my-native-mod
But gitlab-runner
is trying to install the module from builds
folder i.e.
file:builds/0/project-0/native_modules/react-native-my-native-mod
As a result, the checksum is changed and it creates the above-mentioned error.
Or maybe some other reason behind it.
How to solve this?
2
Answers
The directory
builds/0/project-0/
is the clone of the remote repository and the content ofbuilds/0/project-0/native_modules/react-native-my-native-mod
is the same asnative_modules/react-native-my-native-mod
in the repo.To fix it, clone the repo, and run
and push the updated
yarn.lock
to the repository. This will fix the issue.Ideally, you’d figure out why yarn ends up with a different package checksum in the CI environment, and then fix the cause so
yarn.lock
isn’t modified in the first place. That might be difficult, though 😄 (other people are reporting similar issues with no solution so far, e.g. here).As a workaround, you could explicitly update the checksum/hash for your (well-known/trusted) local package before running
yarn install --immutable
, e.g. like this:After that, your install shouldn’t fail anymore under normal circumstances, but will still fail if any other checksum mismatch occurs.