I\'m trying to run an existing React Native project that uses Metro Bundler. My operating system is Ubuntu 20.04 and I\'ve tried to run the app both on a physical Android device
If you have nvm installed, its even simpler. To check this, run
nvm --version
then to install the latest lts version of node, run
nvm install --lts
That's what worked for me, let me know if that helps
I got this too today when doing a build. (running node 12.8.3)
I reinstalled the follow package:
npm install graceful-fs --save-dev
This solved the above problem.
I had a very similar problem on CI, but it works normally on my local machine (Node 13). In the CI, when building the project on CircleCI or on AppCenter with a code that I already released two months ago it throws the error below. It just does not make sense, it's like node had broken dynamically.
I tested the same code with node 10, 12 and 14, but now it works just with node 10 (10.22.0).
The error I had:
/home/circleci/my-app/node_modules/@react-native-community/cli/node_modules/graceful-fs/polyfills.js:285
if (cb) cb.apply(this, arguments)
^
TypeError: cb.apply is not a function
at /home/circleci/my-app/node_modules/@react-native-community/cli/node_modules/graceful-fs/polyfills.js:285:20
at FSReqCallback.oncomplete (fs.js:169:5)
> Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1
UPDATE
What solved my problem was to add a resolution to the package.json
to do not allow any lib to use a version of graceful-fs that is before "4.2.4". Now it works again with node 12.
PS: Don't forget to run yarn
or npm run install
to update your .lock
. If this solution does not work for you, please add a comment to this thread related to this problem on Node 12.18.3
"devDependencies": {
...
},
"resolutions": {
"graceful-fs": "4.2.4"
},
I solved it on both my computers. One needed more work on it.
Option 1:
C:\Users(your username)\AppData\Roaming
npm clean cache -force
, or npm cache clean -force
on windows ( — force is now required to clean cache)Option 2:
C:\Users(your username)\AppData\Roaming
npm clean cache -force
on linux, or npm cache clean
on windows ( — force is now required to clean cache)In my case I was trying to use Husky
and this error occurs:
husky > commit-msg (node v15.6.0)
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! ~/.npm/_logs/2021-01-24T06_04_04_218Z-debug.log
>>> Installation [ 'commitlint@latest' ] fail with code 1 <<<
husky > commit-msg hook failed (add --no-verify to bypass)
I run the command below and problem was solved
npm i -D commitlint