react-native-clean-project icon indicating copy to clipboard operation
react-native-clean-project copied to clipboard

Command 'wipe node_modules' failed with code: 1

Open sushrut-desora opened this issue 2 years ago • 41 comments

When I run the command npx react-native clean-project-auto I get the following error and the process terminates.

Error running 'wipe node_modules': rm: 
Error running 'wipe node_modules': fts_read
Error running 'wipe node_modules': : 
Error running 'wipe node_modules': No such file or directory

❌  Command 'wipe node_modules' failed with code: 1
/Users/sushrut/Documents/GitHub/Desora-Smoker-RN/node_modules/@react-native-community/cli/build/index.js:99
    const message = err.message.replace(/\.$/, '');
                        ^

TypeError: Cannot read property 'message' of undefined
    at handleError (/Users/sushrut/Documents/GitHub/Desora-Smoker-RN/node_modules/@react-native-community/cli/build/index.js:99:25)
    at Command.handleAction (/Users/sushrut/Documents/GitHub/Desora-Smoker-RN/node_modules/@react-native-community/cli/build/index.js:189:7)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Library Version: 3.6.4 OS: macOS Big Sur 11.5.2

sushrut-desora avatar Sep 10 '21 14:09 sushrut-desora

Is the node_modules folder empty before running the command?

pmadruga avatar Sep 11 '21 13:09 pmadruga

No, it wasn't empty before I ran the command. Even after I encountered the error, the node_modules folder was present(typically it is deleted if the command succeeds). Although I did not check if it was empty after the error. I ended up deleting it manually in this case. I tried running the command a few times this morning and did not encounter the error. I will try to reproduce the issue and give additional details. Although the node_modules folder wasn't completely deleted and wasn't empty either. Did something change in version 3.6.4? I believe it used to completely delete the node_modules folder previously and throw an error on next run(as expected) saying something like "clean-project" not found. Now I can keep running npx react-native clean-project-auto repeatedly without even doing npm install.

sushrut-desora avatar Sep 11 '21 14:09 sushrut-desora

I got the same error. node_modules is not empty before, but after running the command and getting this error, node_modules/.bin is gone, so no commands will work anymore, e.g npx react-native clean-project will fail after that due to the react-native command no longer being found. Need to run rm -rf node_modules && yarn to get it back

mifi avatar Sep 11 '21 14:09 mifi

A few questions:

  • Which node version are you running?
  • Which @react-native-community/cli version do you have?
  • Does this happen every time?
  • At which task does this happen for you? (Some happen on the wipe node_modules and some on the clean android project)

Thanks. I can't seem to replicate it but let's get your feedback and fix this asap.

pmadruga avatar Sep 26 '21 21:09 pmadruga

UPDATE: Nevermind I think my ./gradlew folder just didn't exist. It would be nice if it skipped the step if the folder doesn't exist instead of erroring out just to avoid confusion hahaha.

Getting error on react-native clean-project-auto

yarn run v1.22.10
$ react-native clean-project-auto

Executing fully-automated project clean.
Use 'react-native clean-project' for more control
Use `./node_modules/.bin/react-native-clean-project' for total control

Error running 'wipe iOS build artifacts': No matching processes belonging to you were found

✅  wipe android build folder task has finished running in 40ms.
✅  wipe temporary caches task has finished running in 32ms.
✅  npm ci task has finished running in 15ms.
✅  watchman cache clear (if watchman is installed) task has finished running in 66ms.
✅  wipe user iOS Pods cache task has finished running in 506ms.
Error running 'clean android project': 

Error running 'clean android project': FAILURE: Build failed with an exception.

* Where:

Error running 'clean android project': Script '/Users/kailashuniyal/Desktop/cwings-delivery-app/node_modules/react-native-unimodules/gradle.groovy' line: 34

* What went wrong:

Error running 'clean android project': A problem occurred evaluating settings 'CwingsDeliveryApp'.
> 
Error running 'clean android project':  (No such file or directory)

* Try:

Error running 'clean android project': Run with --stacktrace
Error running 'clean android project':  option to get the stack trace. Run with 
Error running 'clean android project': --info or --debug option to get more log output. Run with --scan
Error running 'clean android project':  to get full insights.


Error running 'clean android project': * Get more help at https://help.gradle.org


Error running 'clean android project': BUILD FAILED in 6s

❌  Command 'clean android project' failed with code: 1
/Users/kailashuniyal/Desktop/cwings-delivery-app/node_modules/@react-native-community/cli/build/index.js:99
    const message = err.message.replace(/\.$/, '');
                        ^

TypeError: Cannot read property 'message' of undefined
    at handleError (/Users/kailashuniyal/Desktop/cwings-delivery-app/node_modules/@react-native-community/cli/build/index.js:99:25)
    at Command.handleAction (/Users/kailashuniyal/Desktop/cwings-delivery-app/node_modules/@react-native-community/cli/build/index.js:189:7)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
info Fetching system and libraries information...
System:
    OS: macOS 11.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 902.64 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.4.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.19.1 - /usr/local/bin/npm
    Watchman: 2021.06.07.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.0 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 28, 29, 30, 31
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7486908
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.1 => 0.64.1 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

KrisLau avatar Sep 27 '21 13:09 KrisLau

That makes sense. Yes, definitely think there should be a fallback.

I’m also working on releasing a version that outputs a log file. A lot of times I can’t replicate the community’s problems so the log would help.

pmadruga avatar Sep 27 '21 14:09 pmadruga

@pmadruga, I believe this is a concurrency problem. It seems like executeTask is returning a promise, but on index.js we're not waiting promise to resolve/reject.

if (options.getWipeiOSBuild()) {
  executeTask(tasks.wipeiOSBuildFolder);
}
if (options.getWipeiOSPods()) {
  executeTask(tasks.wipeiOSPodsFolder);
}
if (options.getWipeSystemiOSPodsCache()) {
  executeTask(tasks.wipeSystemiOSPodsCache);
}

In other words, we're trying to execute these tasks at the same time without knowing which one will be resolved/rejected first. This is causing node_modules to be removed before tasks.cleanAndroidProject which is probably throwing the above.

If I execute the process with flag --keep-node-modules, everything works fine on my end.

OnurVar avatar Sep 27 '21 15:09 OnurVar

I believe the tasks are mutually exclusive. But I'm puzzled by this:

If I execute the process with flag --keep-node-modules, everything works fine on my end.

Can someone in this thread that has this problem try the solution @OnurVar mentioned? Thanks!

pmadruga avatar Sep 28 '21 21:09 pmadruga

A few questions:

  • Which node version are you running?
  • Which @react-native-community/cli version do you have?
  • Does this happen every time?
  • At which task does this happen for you? (Some happen on the wipe node_modules and some on the clean android project)

Thanks. I can't seem to replicate it but let's get your feedback and fix this asap.

Node Version: v16.1.0 npx react-native --version: 5.0.1 Does this happen every time: yes Happens at 'wipe node_modules' and fails to delete the node_modules folder.

sushrut-desora avatar Sep 28 '21 21:09 sushrut-desora

I'm getting a similar error:

Error running 'clean android project':

Error running 'clean android project': FAILURE: Build failed with an exception.

* Where:
Error running 'clean android project':

Error running 'clean android project': Script '/Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 242


Error running 'clean android project': * What went wrong:

Error running 'clean android project': A problem occurred evaluating script.

Error running 'clean android project': >
Error running 'clean android project': Calling `[node, /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/bin.js, config]` finished with an exception. Error message: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
Error running 'clean android project':


Error running 'clean android project':   The current character read is 'E' with an int value of 69
Error running 'clean android project':

Error running 'clean android project':   Unable to determine the current character, it is not a string, number, array, or object

Error running 'clean android project':   line number 1

Error running 'clean android project':   index number 0
Error running 'clean android project':

Error running 'clean android project':   Error: Cannot find module 'path-is-absolute'Require stack:- /Users/curthoward/Work/project-react-native/node_modules/glob/glob.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli-platform-ios/build/config/findProject.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli-platform-ios/build/config/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli-platform-ios/build/index.js- /Users/curthoward/Work/project-react-native/node_modules/react-native/react-native.config.js- /Users/curthoward/Work/project-react-native/node_modules/import-fresh/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/node_modules/cosmiconfig/dist/loaders.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/node_modules/cosmiconfig/dist/createExplorer.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/node_modules/cosmiconfig/dist/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/tools/config/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/commands/install/install.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/commands/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/bin.js    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)    at Function.Module._load (internal/modules/cjs/loader.js:667:27)    at Module.require (internal/modules/cjs/loader.js:887:19)    at require (internal/modules/cjs/helpers.js:74:18)    at Object.<anonymous> (/Users/curthoward/Work/project-react-native/node_modules/glob/glob.js:51:18)    at Module._compile (internal/modules/cjs/loader.js:999:30)    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)    at Module.load (internal/modules/cjs/loader.js:863:32)    at Function.Module._load (internal/modules/cjs/loader.js:708:14)    at Module.require (internal/modules/cjs/loader.js:887:19)info Run CLI with --verbose flag for more details.

Error running 'clean android project':   ^. Output: Error: Cannot find module 'path-is-absolute'Require stack:- /Users/curthoward/Work/project-react-native/node_modules/glob/glob.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli-platform-ios/build/config/findProject.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli-platform-ios/build/config/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli-platform-ios/build/index.js- /Users/curthoward/Work/project-react-native/node_modules/react-native/react-native.config.js- /Users/curthoward/Work/project-react-native/node_modules/import-fresh/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/node_modules/cosmiconfig/dist/loaders.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/node_modules/cosmiconfig/dist/createExplorer.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/node_modules/cosmiconfig/dist/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/tools/config/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/commands/install/install.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/commands/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/index.js- /Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/bin.js    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)    at Function.Module._load (internal/modules/cjs/loader.js:667:27)    at Module.require (internal/modules/cjs/loader.js:887:19)    at require (internal/modules/cjs/helpers.js:74:18)    at Object.<anonymous> (/Users/curthoward/Work/project-react-native/node_modules/glob/glob.js:51:18)    at Module._compile (internal/modules/cjs/loader.js:999:30)    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)    at Module.load (internal/modules/cjs/loader.js:863:32)    at Function.Module._load (internal/modules/cjs/loader.js:708:14)    at Module.require (internal/modules/cjs/loader.js:887:19)info Run CLI with --verbose flag for more details.

* Try:
Run with --stacktrace option to get the stack trace. Run with
Error running 'clean android project': --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
Error running 'clean android project':

❌  Command 'clean android project' failed with code: 1
(node:32526) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'message' of undefined
    at handleError (/Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/index.js:99:25)
    at Command.handleAction (/Users/curthoward/Work/project-react-native/node_modules/@react-native-community/cli/build/index.js:189:7)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:32526) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:32526) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Node version: 12.20.0 npx react-native --version: 6.0.0 Does this happen every time: yes

curt-tophatter avatar Oct 18 '21 17:10 curt-tophatter

Just to give an update - I've been working on this fix (although I can't seem to replicate it). Progress is happening (despite being slightly slow).

pmadruga avatar Oct 22 '21 08:10 pmadruga

Hi everyone,

As you know, I can't replicate it, but I've made the tasks truly asynchronous to avoid concurrency problems. For this, I need help with testing so please give it a go using

npm install react-native-clean-project@alpha

which will install version 4.0-alpha. One downside is that the tasks will take longer, but I'm investigating whether using threads will speed up the process. I also had to bump the minimum required node version, hence the jump to version 4 - but hopefully it won't cause breaking changes (min version of node is node >= 10).

I also need a code review on #84. Looking forward to your feedback!

pmadruga avatar Oct 27 '21 07:10 pmadruga

im getting this error in 1 project but not in another, even when i tried the same version.

i downloaded the alpha version to try and it still fails for me:

stderr chunk: :ReactNative:Unexpected empty result of running '[node, -e, console.log(require('react-native/cli').bin);]' command.
:ReactNative:Running '[node, -e, console.log(require('react-native/cli').bin);]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 213

* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:905  throw err;  ^Error: Cannot find module 'joi'Require stack:- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native/cli.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/android/[eval]    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)    at Function.Module._load (internal/modules/cjs/loader.js:746:27)    at Module.require (internal/modules/cjs/loader.js:974:19)    at require (internal/modules/cjs/helpers.js:92:18)    at _joi (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js:9:39)    at Object.<anonymous> (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js:26:17)    at Module._compile (internal/modules/cjs/loader.js:1085:14)    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)    at Module.load (internal/modules/cjs/loader.js:950:32)    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {  code: 'MODULE_NOT_FOUND',  requireStack: [    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native/cli.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/android/[eval]'  ]}

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

(node:9123) UnhandledPromiseRejectionWarning: Error: subprocess error exit 1, :ReactNative:Unexpected empty result of running '[node, -e, console.log(require('react-native/cli').bin);]' command.
:ReactNative:Running '[node, -e, console.log(require('react-native/cli').bin);]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 213

* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:905  throw err;  ^Error: Cannot find module 'joi'Require stack:- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native/cli.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/android/[eval]    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)    at Function.Module._load (internal/modules/cjs/loader.js:746:27)    at Module.require (internal/modules/cjs/loader.js:974:19)    at require (internal/modules/cjs/helpers.js:92:18)    at _joi (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js:9:39)    at Object.<anonymous> (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js:26:17)    at Module._compile (internal/modules/cjs/loader.js:1085:14)    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)    at Module.load (internal/modules/cjs/loader.js:950:32)    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {  code: 'MODULE_NOT_FOUND',  requireStack: [    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native/cli.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/android/[eval]'  ]}

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

    at executeTask (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native-clean-project/source/internals/executor.js:40:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native-clean-project/source/plugin.js:23:24
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9123) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9123) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Adnan-Bacic avatar Oct 27 '21 16:10 Adnan-Bacic

Hi @Adnan-Bacic, thank you for testing the alpha!

A few questions:

  1. Did you run the clean-project-auto or the clean-project?
  2. Is one of your dependencies @hapi/joi ?
  3. If I understand, on one of your projects, it runs fine?

I've improved logging a bit on 4.0.0-alpha2.0 - please update.

pmadruga avatar Oct 28 '21 07:10 pmadruga

Hi @Adnan-Bacic, thank you for testing the alpha!

A few questions:

  1. Did you run the clean-project-auto or the clean-project?
  2. Is one of your dependencies @hapi/joi ?
  3. If I understand, on one of your projects, it runs fine?

I've improved logging a bit on 4.0.0-alpha2.0 - please update.

no problem, this is an awesome library

1: both are running react-native 0.66.1. both are using the auto command

2: im not using @hapi/joi directly.

but if i search my project for "hapi" i see @hapi/hoek and @hapi/topo in yarn.lock. they seem to be dependencies for joi@npm:^17.2.1

if i search the project for "joi" i see joi in yarn.lock. specifically as a dependency for @react-native-community/cli@npm:^6.0.0

and @react-native-community/cli@npm:^6.0.0 is a dependency of react-native, which im on 0.66.1 as previously mentioned.

3: yes one project is running 3.6.4 without errors. another project i tried the same version and get errors

error on 3.6.4:

Error running 'clean android project': 

Error running 'clean android project': FAILURE: Build failed with an exception.

* Where:

Error running 'clean android project': Settings file '/Users/REMOVED-NAME-AND-PROJECT-NAME/android/settings.gradle' line: 2

* What went wrong:
Error running 'clean android project': 

Error running 'clean android project': A problem occurred evaluating settings 'APP_NAME'.
> 
Error running 'clean android project': Could not read script '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.

* Try:
Run with --stacktrace
Error running 'clean android project':  option to get the stack trace. Run with --info or --debug
Error running 'clean android project':  option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s

❌  Command 'clean android project' failed with code: 1
(node:11145) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'message' of undefined
    at handleError (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:99:25)
    at Command.handleAction (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:189:7)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11145) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11145) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

not the same error as OP but others in the thread have gotten the same error.

then i tried the 4.0.0-alpha1.0 and get the error from my previous comment.

just tried 4.0.0-alpha2.0 and it also fails, results from 4.0.0-alpha2.0:

stderr chunk: :ReactNative:Unexpected empty result of running '[node, -e, console.log(require('react-native/cli').bin);]' command.
:ReactNative:Running '[node, -e, console.log(require('react-native/cli').bin);]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 213

* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:905  throw err;  ^Error: Cannot find module 'joi'Require stack:- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native/cli.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/android/[eval]    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)    at Function.Module._load (internal/modules/cjs/loader.js:746:27)    at Module.require (internal/modules/cjs/loader.js:974:19)    at require (internal/modules/cjs/helpers.js:92:18)    at _joi (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js:9:39)    at Object.<anonymous> (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js:26:17)    at Module._compile (internal/modules/cjs/loader.js:1085:14)    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)    at Module.load (internal/modules/cjs/loader.js:950:32)    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {  code: 'MODULE_NOT_FOUND',  requireStack: [    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native/cli.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/android/[eval]'  ]}

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

(node:23502) UnhandledPromiseRejectionWarning: Error: 

Task "clean android project" 
Error: :ReactNative:Unexpected empty result of running '[node, -e, console.log(require('react-native/cli').bin);]' command.
:ReactNative:Running '[node, -e, console.log(require('react-native/cli').bin);]' command failed.

FAILURE: Build failed with an exception.

* Where:
Script '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 213

* What went wrong:
A problem occurred evaluating script.
> internal/modules/cjs/loader.js:905  throw err;  ^Error: Cannot find module 'joi'Require stack:- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native/cli.js- /Users/REMOVED-NAME-AND-PROJECT-NAME/android/[eval]    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)    at Function.Module._load (internal/modules/cjs/loader.js:746:27)    at Module.require (internal/modules/cjs/loader.js:974:19)    at require (internal/modules/cjs/helpers.js:92:18)    at _joi (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js:9:39)    at Object.<anonymous> (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js:26:17)    at Module._compile (internal/modules/cjs/loader.js:1085:14)    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)    at Module.load (internal/modules/cjs/loader.js:950:32)    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {  code: 'MODULE_NOT_FOUND',  requireStack: [    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/schema.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native/cli.js',    '/Users/REMOVED-NAME-AND-PROJECT-NAME/android/[eval]'  ]}

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
. 
Exit code: 1


    at executeTask (/Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native-clean-project/source/internals/executor.js:40:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async /Users/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native-clean-project/source/plugin.js:23:24
(Use `node --trace-warnings ...` to show where the warning was created)
(node:23502) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:23502) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
stderr chunk: No matching processes belonging to you were found

looks like its still complaining about joi

Adnan-Bacic avatar Oct 28 '21 08:10 Adnan-Bacic

Thank you for this. Let me investigate it more with this information and will work on alpha3.

I'll write here as soon as I have a release.

PS: The release of alpha2 only included better logging.

pmadruga avatar Oct 28 '21 11:10 pmadruga

Hi @pmadruga for the alpha version. I was able to test the alpha2 version and I think we're on right direction.

I tested alpha version by applying some extra console logs to see if concurrency problem still exists or not.

Here is where I've made the changes on my local


  console.log('Flag #1');
  options.rlInterface.close();

  await executeTask(tasks.watchmanCacheClear);
  await executeTask(tasks.wipeTempCaches);
  console.log('Flag #2');

  if (options.getWipeiOSBuild()) {
    await executeTask(tasks.wipeiOSBuildFolder);
  }

  console.log('Flag #3');
  if (options.getWipeiOSPods()) {
    await executeTask(tasks.wipeiOSPodsFolder);
  }

  console.log('Flag #4');
  if (options.getWipeSystemiOSPodsCache()) {
    await executeTask(tasks.wipeSystemiOSPodsCache);
  }

  console.log('Flag #5');
  if (options.getUpdatePods()) {
    await executeTask(tasks.updatePods);
  }

  console.log('Flag #6');
  if (options.getWipeUseriOSPodsCache()) {
    await executeTask(tasks.wipeUseriOSPodsCache);
  }
  console.log('Flag #7');
  if (options.getWipeAndroidBuild()) {
    await executeTask(tasks.wipeAndroidBuildFolder);
  }
... and so on

I ran react-native clean-project and accepted every option (by giving answer y) and here is the result.

Wipe iOS build folder? (Y/n) y
Wipe iOS Pods folder? (Y/n) y
Wipe system iOS Pods cache? (Y/n) y
Wipe user iOS Pods cache? (Y/n) y
Update pods? (Y/n) y
Wipe android build folder? (Y/n) y
Clean Android project? (Y/n) y
Wipe node_modules folder? (Y/n) y
Update brew? (Y/n) n
Flag #1
started: watchman cache clear (if watchman is installed)
✅  "watchman cache clear (if watchman is installed)" task has finished running in 66ms.
started: wipe temporary caches
✅  "wipe temporary caches" task has finished running in 12ms.
Flag #2
started: wipe iOS build artifacts
stderr chunk: No matching processes belonging to you were found

✅  "wipe iOS build artifacts" task has finished running in 3s.
Flag #3
started: wipe iOS Pods folder
✅  "wipe iOS Pods folder" task has finished running in 4s.
Flag #4
started: wipe system iOS Pods cache
✅  "wipe system iOS Pods cache" task has finished running in 8s.
Flag #5
started: update iOS Pods
✅  "update iOS Pods" task has finished running in 497s.
Flag #6
started: wipe user iOS Pods cache
✅  "wipe user iOS Pods cache" task has finished running in 424ms.
Flag #7
started: wipe android build folder
✅  "wipe android build folder" task has finished running in 9ms.
Flag #8
Flag #9
started: wipe node_modules
✅  "wipe node_modules" task has finished running in 4s.
started: yarn cache clean (if yarn is installed)
✅  "yarn cache clean (if yarn is installed)" task has finished running in 4s.
started: npm ci
✅  "npm ci" task has finished running in 7ms.
started: yarn install (if yarn is installed)
stderr chunk: warning " > [email protected]" has unmet peer dependency "lottie-ios@^3.2.3".
warning "react-native > react-native-codegen > [email protected]" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning " > [email protected]" has incorrect peer dependency "react@^16.8.1".
warning " > [email protected]" has incorrect peer dependency "react@^16.8.3".
warning " > [email protected]" has incorrect peer dependency "react-native@^0.59.9 || ^0.60.0 || ^0.61.0".
warning " > [email protected]" has incorrect peer dependency "react-native@^0.64".
warning " > [email protected]" has unmet peer dependency "[email protected]".
warning " > [email protected]" has incorrect peer dependency "[email protected]".
warning " > [email protected]" has incorrect peer dependency "react-native-webview@^7.4.3".
warning " > [email protected]" has incorrect peer dependency "react@^16.9".
warning " > [email protected]" has incorrect peer dependency "react-native@>=0.60 <0.62".
warning " > [email protected]" has unmet peer dependency "react-native-windows@^0.61.0-beta.58".
warning " > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0".
warning " > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0".

✅  "yarn install (if yarn is installed)" task has finished running in 55s.
Flag #10
started: clean android project
✅  "clean android project" task has finished running in 22s.
Flag #11

As you can see in the result, flags are logged after individual task executed respectively, which means concurrency problems is solved.

I also run yarn react-native-clean-project and since it's same with react-native clean-project, I got the same result above which is successful.

But when I ran react-native clean-project-auto, It failed with error below

stderr chunk: 
FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/REMOVED-NAME-AND-PROJECT-NAME/Projects/REMOVED-NAME-AND-PROJECT-NAME/android/settings.gradle' line: 3

* What went wrong:
A problem occurred evaluating settings 'REMOVED-NAME-AND-PROJECT-NAME'.
> Could not read script '/Users/REMOVED-NAME-AND-PROJECT-NAME/Projects/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s

(node:81819) UnhandledPromiseRejectionWarning: Error: 

Task "clean android project" 
Error: 
FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/REMOVED-NAME-AND-PROJECT-NAME/Projects/REMOVED-NAME-AND-PROJECT-NAME/android/settings.gradle' line: 3

* What went wrong:
A problem occurred evaluating settings 'REMOVED-NAME-AND-PROJECT-NAME'.
> Could not read script '/Users/REMOVED-NAME-AND-PROJECT-NAME/Projects/REMOVED-NAME-AND-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s
. 
Exit code: 1


    at executeTask (/Users/REMOVED-NAME-AND-PROJECT-NAME/Projects/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native-clean-project/source/internals/executor.js:40:11)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async /Users/REMOVED-NAME-AND-PROJECT-NAME/Projects/REMOVED-NAME-AND-PROJECT-NAME/node_modules/react-native-clean-project/source/plugin.js:23:24
(node:81819) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:81819) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

As you can see on the result, there is unhandled promise. Probably clean-project-auto plugin method is ignoring async task executions.

OnurVar avatar Oct 28 '21 14:10 OnurVar

Firstly, thank you for the great debug session - it really helps in tackling this.

Yes, I have the same gut feeling. From reading the code, I doubt that it's truly asynchronous. So in the next few days, I'm going to rewrite it and hopefully, alpha3 will have it fixed.

I'll write here as soon as alpha3 is released.

pmadruga avatar Oct 28 '21 16:10 pmadruga

Alright, now alpha4 has some fixes! Please give it a go using:

npm i [email protected]

Thank you!

pmadruga avatar Oct 29 '21 17:10 pmadruga

I've tested alpha4 and it seems like there is a problem in the order of autoTasks list:

const autoTasks = [
  tasks.wipeiOSBuildFolder,
  tasks.wipeiOSPodsFolder,
  tasks.wipeSystemiOSPodsCache,
  tasks.wipeUseriOSPodsCache,
  tasks.wipeAndroidBuildFolder,
  tasks.watchmanCacheClear,
  tasks.wipeTempCaches,
  tasks.wipeNodeModules,
  tasks.yarnCacheClean,
  tasks.npmCacheVerify,
  tasks.npmInstall,
  tasks.cleanAndroidProject <---
];

I think this is the right order:

const autoTasks = [
  tasks.wipeiOSBuildFolder,
  tasks.wipeiOSPodsFolder,
  tasks.wipeSystemiOSPodsCache,
  tasks.wipeUseriOSPodsCache,
  tasks.wipeAndroidBuildFolder,
  tasks.cleanAndroidProject, <---
  tasks.watchmanCacheClear,
  tasks.wipeTempCaches,
  tasks.wipeNodeModules,
  tasks.yarnCacheClean,
  tasks.npmCacheVerify,
  tasks.npmInstall
];

tasks.cleanAndroidProject should run before tasks.wipeNodeModules since node_modules folder is required in clean android project.

OnurVar avatar Oct 30 '21 13:10 OnurVar

my error for 4.0.0-alpha3.0:

node:1870) UnhandledPromiseRejectionWarning: Error: 

Task "clean android project" 
Error: 
FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/adb/dev/REMOVED-PROJECT-NAME/android/settings.gradle' line: 2

* What went wrong:
A problem occurred evaluating settings 'REMOVED-PROJECT-NAME'.
> Could not read script '/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
. 
Exit code: 1


    at executeTask (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native-clean-project/source/internals/executor.js:40:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async executeTasks (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native-clean-project/source/plugin.js:23:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1870) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1870) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

my error for 4.0.0-alpha4.0:

(node:8151) UnhandledPromiseRejectionWarning: Error: Cannot find module 'chalk'
Require stack:
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/errors.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at _chalk (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js:9:39)
    at Object.error (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js:46:22)
    at handleError (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:101:24)
    at Command.handleAction (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:189:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8151) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8151) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

now its complaining about some "chalk" library. its not a dependency for the project but i see it in yarn.lock under a bunch of jest dependencies.

Adnan-Bacic avatar Oct 31 '21 17:10 Adnan-Bacic

I've tested alpha4 and it seems like there is a problem in the order of autoTasks list:

const autoTasks = [
  tasks.wipeiOSBuildFolder,
  tasks.wipeiOSPodsFolder,
  tasks.wipeSystemiOSPodsCache,
  tasks.wipeUseriOSPodsCache,
  tasks.wipeAndroidBuildFolder,
  tasks.watchmanCacheClear,
  tasks.wipeTempCaches,
  tasks.wipeNodeModules,
  tasks.yarnCacheClean,
  tasks.npmCacheVerify,
  tasks.npmInstall,
  tasks.cleanAndroidProject <---
];

I think this is the right order:

const autoTasks = [
  tasks.wipeiOSBuildFolder,
  tasks.wipeiOSPodsFolder,
  tasks.wipeSystemiOSPodsCache,
  tasks.wipeUseriOSPodsCache,
  tasks.wipeAndroidBuildFolder,
  tasks.cleanAndroidProject, <---
  tasks.watchmanCacheClear,
  tasks.wipeTempCaches,
  tasks.wipeNodeModules,
  tasks.yarnCacheClean,
  tasks.npmCacheVerify,
  tasks.npmInstall
];

tasks.cleanAndroidProject should run before tasks.wipeNodeModules since node_modules folder is required in clean android project.

When clean android project runs, the node_modules folder exists because it runs after npm install. It now follows the same sequence as the interactive one.

Do you get an error when running any of interactive/non-interactive?

pmadruga avatar Oct 31 '21 18:10 pmadruga

my error for 4.0.0-alpha3.0:

node:1870) UnhandledPromiseRejectionWarning: Error: 

Task "clean android project" 
Error: 
FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/adb/dev/REMOVED-PROJECT-NAME/android/settings.gradle' line: 2

* What went wrong:
A problem occurred evaluating settings 'REMOVED-PROJECT-NAME'.
> Could not read script '/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
. 
Exit code: 1


    at executeTask (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native-clean-project/source/internals/executor.js:40:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async executeTasks (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native-clean-project/source/plugin.js:23:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1870) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1870) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

my error for 4.0.0-alpha4.0:

(node:8151) UnhandledPromiseRejectionWarning: Error: Cannot find module 'chalk'
Require stack:
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/errors.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at _chalk (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js:9:39)
    at Object.error (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js:46:22)
    at handleError (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:101:24)
    at Command.handleAction (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:189:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8151) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8151) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

now its complaining about some "chalk" library. its not a dependency for the project but i see it in yarn.lock under a bunch of jest dependencies.

At which task is the error being thrown?

pmadruga avatar Oct 31 '21 18:10 pmadruga

my error for 4.0.0-alpha3.0:

node:1870) UnhandledPromiseRejectionWarning: Error: 

Task "clean android project" 
Error: 
FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/adb/dev/REMOVED-PROJECT-NAME/android/settings.gradle' line: 2

* What went wrong:
A problem occurred evaluating settings 'REMOVED-PROJECT-NAME'.
> Could not read script '/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
. 
Exit code: 1


    at executeTask (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native-clean-project/source/internals/executor.js:40:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async executeTasks (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native-clean-project/source/plugin.js:23:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1870) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1870) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

my error for 4.0.0-alpha4.0:

(node:8151) UnhandledPromiseRejectionWarning: Error: Cannot find module 'chalk'
Require stack:
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/errors.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at _chalk (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js:9:39)
    at Object.error (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js:46:22)
    at handleError (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:101:24)
    at Command.handleAction (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:189:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8151) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8151) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

now its complaining about some "chalk" library. its not a dependency for the project but i see it in yarn.lock under a bunch of jest dependencies.

At which task is the error being thrown?

clean android, every time

Adnan-Bacic avatar Oct 31 '21 18:10 Adnan-Bacic

my error for 4.0.0-alpha3.0:

node:1870) UnhandledPromiseRejectionWarning: Error: 

Task "clean android project" 
Error: 
FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/adb/dev/REMOVED-PROJECT-NAME/android/settings.gradle' line: 2

* What went wrong:
A problem occurred evaluating settings 'REMOVED-PROJECT-NAME'.
> Could not read script '/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
. 
Exit code: 1


    at executeTask (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native-clean-project/source/internals/executor.js:40:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async executeTasks (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native-clean-project/source/plugin.js:23:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1870) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1870) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

my error for 4.0.0-alpha4.0:

(node:8151) UnhandledPromiseRejectionWarning: Error: Cannot find module 'chalk'
Require stack:
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/errors.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/tools/config/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/install/install.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/commands/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js
- /Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/react-native/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at _chalk (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js:9:39)
    at Object.error (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli-tools/build/logger.js:46:22)
    at handleError (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:101:24)
    at Command.handleAction (/Users/adb/dev/REMOVED-PROJECT-NAME/node_modules/@react-native-community/cli/build/index.js:189:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8151) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8151) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

now its complaining about some "chalk" library. its not a dependency for the project but i see it in yarn.lock under a bunch of jest dependencies.

At which task is the error being thrown?

clean android, every time

Thanks. Now I'm just spitballing, but can you try rm -r $HOME/.gradle/caches/ (or ./gradlew cleanBuildCache) and then run clean-project-auto?

pmadruga avatar Oct 31 '21 18:10 pmadruga

./gradlew cleanBuildCache

i went with the ./gradlew cleanBuildCache

not sure it does anything:

> Task :app:cleanBuildCache
The Android Gradle plugin's build cache has been deprecated.
It will be removed in version 7.0 of the Android Gradle plugin.
It does not do anything and AGP is now using Gradle caching.
The cleanBuildCache task will also be removed in the same version.

> Task :react-native-safe-area-context:cleanBuildCache
The Android Gradle plugin's build cache has been deprecated.
It will be removed in version 7.0 of the Android Gradle plugin.
It does not do anything and AGP is now using Gradle caching.
The cleanBuildCache task will also be removed in the same version.

> Task :react-native-screens:cleanBuildCache
The Android Gradle plugin's build cache has been deprecated.
It will be removed in version 7.0 of the Android Gradle plugin.
It does not do anything and AGP is now using Gradle caching.
The cleanBuildCache task will also be removed in the same version.

> Task :react-native-vector-icons:cleanBuildCache
The Android Gradle plugin's build cache has been deprecated.
It will be removed in version 7.0 of the Android Gradle plugin.
It does not do anything and AGP is now using Gradle caching.
The cleanBuildCache task will also be removed in the same version.

i then get the same error when running clean with auto.

Adnan-Bacic avatar Oct 31 '21 19:10 Adnan-Bacic

I've tested alpha4 and it seems like there is a problem in the order of autoTasks list:

const autoTasks = [
  tasks.wipeiOSBuildFolder,
  tasks.wipeiOSPodsFolder,
  tasks.wipeSystemiOSPodsCache,
  tasks.wipeUseriOSPodsCache,
  tasks.wipeAndroidBuildFolder,
  tasks.watchmanCacheClear,
  tasks.wipeTempCaches,
  tasks.wipeNodeModules,
  tasks.yarnCacheClean,
  tasks.npmCacheVerify,
  tasks.npmInstall,
  tasks.cleanAndroidProject <---
];

I think this is the right order:

const autoTasks = [
  tasks.wipeiOSBuildFolder,
  tasks.wipeiOSPodsFolder,
  tasks.wipeSystemiOSPodsCache,
  tasks.wipeUseriOSPodsCache,
  tasks.wipeAndroidBuildFolder,
  tasks.cleanAndroidProject, <---
  tasks.watchmanCacheClear,
  tasks.wipeTempCaches,
  tasks.wipeNodeModules,
  tasks.yarnCacheClean,
  tasks.npmCacheVerify,
  tasks.npmInstall
];

tasks.cleanAndroidProject should run before tasks.wipeNodeModules since node_modules folder is required in clean android project.

When clean android project runs, the node_modules folder exists because it runs after npm install. It now follows the same sequence as the interactive one.

Do you get an error when running any of interactive/non-interactive?

You're correct,node_modules folder should be created before clean android project but I'm using Yarn so tasks.npmInstall especially test -f package-lock.json fails since it doesn't exist. I think we should also add tasks.yarnInstall ?

OnurVar avatar Nov 01 '21 00:11 OnurVar

A few questions:

  • Which node version are you running?
  • Which @react-native-community/cli version do you have?
  • Does this happen every time?
  • At which task does this happen for you? (Some happen on the wipe node_modules and some on the clean android project)

Thanks. I can't seem to replicate it but let's get your feedback and fix this asap.


@pmadruga I'm just joining into this conversation as another person experiencing the "clean android project" error.

  1. Which node version are you running?: 14.13.0, then with 16.13.0
  2. Which @react-native-community/cli version do you have?: 3.6.4
  3. Does this happen every time?: yes
  4. At which task does this happen for you?: clean android project

After the above, I then performed the following using node 16.13.0 and yarn 1.22.17:

  1. upgraded from 3.6.4 to 4.0.0-alpha4.0
  2. wiped and reinstalled node_modules
  3. ran yarn clean (npm script = "clean": "react-native clean-project-auto")

Here's my CLI output (when the execution broke, node_modules were not found):

Executing fully-automated project clean.
Use 'react-native clean-project' for more control
Use `./node_modules/.bin/react-native-clean-project' for total control


ℹ️  STARTED: "wipe iOS build artifacts"
✅ FINISHED: "wipe iOS build artifacts" task has finished running in 4s.

ℹ️  STARTED: "wipe iOS Pods folder"
✅ FINISHED: "wipe iOS Pods folder" task has finished running in 12ms.

ℹ️  STARTED: "wipe system iOS Pods cache"
✅ FINISHED: "wipe system iOS Pods cache" task has finished running in 4s.

ℹ️  STARTED: "wipe user iOS Pods cache"
✅ FINISHED: "wipe user iOS Pods cache" task has finished running in 11ms.

ℹ️  STARTED: "wipe android build folder"
✅ FINISHED: "wipe android build folder" task has finished running in 10ms.

ℹ️  STARTED: "watchman cache clear (if watchman is installed)"
✅ FINISHED: "watchman cache clear (if watchman is installed)" task has finished running in 66ms.

ℹ️  STARTED: "wipe temporary caches"
✅ FINISHED: "wipe temporary caches" task has finished running in 17ms.

ℹ️  STARTED: "wipe node_modules"
✅ FINISHED: "wipe node_modules" task has finished running in 6s.

ℹ️  STARTED: "yarn cache clean (if yarn is installed)"
✅ FINISHED: "yarn cache clean (if yarn is installed)" task has finished running in 8s.

ℹ️  STARTED: "npm cache verify"
✅ FINISHED: "npm cache verify" task has finished running in 176s.

ℹ️  STARTED: "npm ci"
✅ FINISHED: "npm ci" task has finished running in 13ms.

ℹ️  STARTED: "clean android project"
node:internal/modules/cjs/loader:933
 const err = new Error(message);
             ^

Error: Cannot find module 'chalk'
Require stack:
- /path/to/my/project/node_modules/@react-native-community/cli-tools/build/logger.js
- /path/to/my/project/node_modules/@react-native-community/cli-tools/build/index.js
- /path/to/my/project/node_modules/@react-native-community/cli/build/tools/config/errors.js
- /path/to/my/project/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js
- /path/to/my/project/node_modules/@react-native-community/cli/build/tools/config/index.js
- /path/to/my/project/node_modules/@react-native-community/cli/build/commands/install/install.js
- /path/to/my/project/node_modules/@react-native-community/cli/build/commands/index.js
- /path/to/my/project/node_modules/@react-native-community/cli/build/index.js
- /path/to/my/project/node_modules/react-native/cli.js
   at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
   at Function.Module._load (node:internal/modules/cjs/loader:778:27)
   at Module.require (node:internal/modules/cjs/loader:1005:19)
   at require (node:internal/modules/cjs/helpers:102:18)
   at _chalk (/path/to/my/project/node_modules/@react-native-community/cli-tools/build/logger.js:9:39)
   at Object.error (/path/to/my/project/node_modules/@react-native-community/cli-tools/build/logger.js:46:22)
   at handleError (/path/to/my/project/node_modules/@react-native-community/cli/build/index.js:101:24)
   at Command.handleAction (/path/to/my/project/node_modules/@react-native-community/cli/build/index.js:189:7) {
 code: 'MODULE_NOT_FOUND',
 requireStack: [
   '/path/to/my/project/node_modules/@react-native-community/cli-tools/build/logger.js',
   '/path/to/my/project/node_modules/@react-native-community/cli-tools/build/index.js',
   '/path/to/my/project/node_modules/@react-native-community/cli/build/tools/config/errors.js',
   '/path/to/my/project/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js',
   '/path/to/my/project/node_modules/@react-native-community/cli/build/tools/config/index.js',
   '/path/to/my/project/node_modules/@react-native-community/cli/build/commands/install/install.js',
   '/path/to/my/project/node_modules/@react-native-community/cli/build/commands/index.js',
   '/path/to/my/project/node_modules/@react-native-community/cli/build/index.js',
   '/path/to/my/project/node_modules/react-native/cli.js'
 ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

jwoo92 avatar Nov 07 '21 14:11 jwoo92

Looks like I'm also in the same boat using automatic cleaning on alpha4.0:

yarn run v1.22.5
$ react-native clean-project-auto

Executing fully-automated project clean.
Use 'react-native clean-project' for more control
Use `./node_modules/.bin/react-native-clean-project' for total control


ℹ️  STARTED: "wipe iOS build artifacts"
✅ FINISHED: "wipe iOS build artifacts" task has finished running in 21s.

ℹ️  STARTED: "wipe iOS Pods folder"
✅ FINISHED: "wipe iOS Pods folder" task has finished running in 10ms.

ℹ️  STARTED: "wipe system iOS Pods cache"
✅ FINISHED: "wipe system iOS Pods cache" task has finished running in 5s.

ℹ️  STARTED: "wipe user iOS Pods cache"
✅ FINISHED: "wipe user iOS Pods cache" task has finished running in 17ms.

ℹ️  STARTED: "wipe android build folder"
✅ FINISHED: "wipe android build folder" task has finished running in 12ms.

ℹ️  STARTED: "watchman cache clear (if watchman is installed)"
✅ FINISHED: "watchman cache clear (if watchman is installed)" task has finished running in 25ms.

ℹ️  STARTED: "wipe temporary caches"
✅ FINISHED: "wipe temporary caches" task has finished running in 29ms.

ℹ️  STARTED: "wipe node_modules"
✅ FINISHED: "wipe node_modules" task has finished running in 24s.

ℹ️  STARTED: "yarn cache clean (if yarn is installed)"
✅ FINISHED: "yarn cache clean (if yarn is installed)" task has finished running in 14s.

ℹ️  STARTED: "npm cache verify"
✅ FINISHED: "npm cache verify" task has finished running in 12s.

ℹ️  STARTED: "npm ci"
✅ FINISHED: "npm ci" task has finished running in 9ms.

ℹ️  STARTED: "clean android project"
(node:82573) UnhandledPromiseRejectionWarning: Error: Cannot find module 'chalk'
Require stack:
- /path/to/my-project/node_modules/@react-native-community/cli-tools/build/logger.js
- /path/to/my-project/node_modules/@react-native-community/cli-tools/build/index.js
- /path/to/my-project/node_modules/@react-native-community/cli/build/tools/config/errors.js
- /path/to/my-project/node_modules/@react-native-community/cli/build/tools/config/readConfigFromDisk.js
- /path/to/my-project/node_modules/@react-native-community/cli/build/tools/config/index.js
- /path/to/my-project/node_modules/@react-native-community/cli/build/commands/install/install.js
- /path/to/my-project/node_modules/@react-native-community/cli/build/commands/index.js
- /path/to/my-project/node_modules/@react-native-community/cli/build/index.js
- /path/to/my-project/node_modules/react-native/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at _chalk (/path/to/my-project/node_modules/@react-native-community/cli-tools/build/logger.js:9:39)
    at Object.error (/path/to/my-project/node_modules/@react-native-community/cli-tools/build/logger.js:46:22)
    at handleError (/path/to/my-project/node_modules/@react-native-community/cli/build/index.js:101:24)
    at Command.handleAction (/path/to/my-project/node_modules/@react-native-community/cli/build/index.js:189:7)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:82573) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:82573) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

curt-tophatter avatar Nov 08 '21 17:11 curt-tophatter

@roryabraham I can see that the alpha version solves this issue for you - can you confirm?

pmadruga avatar Jan 13 '22 20:01 pmadruga