Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad error message if a module is not found #219

Closed
GitToTheHub opened this issue Dec 30, 2024 · 4 comments
Closed

Bad error message if a module is not found #219

GitToTheHub opened this issue Dec 30, 2024 · 4 comments

Comments

@GitToTheHub
Copy link

Bug Report

I'm new in plugin development and tried to write a hook. I used as an example
https://github.com/AyogoHealth/cordova-plugin-app-scope/blob/main/src/prepare_hook.js

When I was executing the line: const et = require('elementtree'); I got an error on the console:

TypeError [ERR_INVALID_ARG_TYPE]: The "code" argument must be of type number. Received type string ('MODULE_NOT_FOUND')
    at process.set [as exitCode] (node:internal/bootstrap/node:123:9)
    at /Users/manuelbeck/.nvm/versions/node/v22.9.0/lib/node_modules/cordova/bin/cordova:32:22

I was wondering about this error message and looked in cordova:32:22. The line which was throwing the error was:
process.exitCode = err.code || 1;

I understood, the console was complaining that code was a string instead of a number. When I did console.log(err) in the script, I saw the error message:

Error: Cannot find module 'elementtree'
Require stack:
- /Users/manuelbeck/Projekte/GitHub/cordova-plugin-local-notifications/src/prepare_hook.js
- /Users/manuelbeck/.nvm/versions/node/v22.9.0/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js
- /Users/manuelbeck/.nvm/versions/node/v22.9.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js
- /Users/manuelbeck/.nvm/versions/node/v22.9.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/plugman.js
- /Users/manuelbeck/.nvm/versions/node/v22.9.0/lib/node_modules/cordova/node_modules/cordova-lib/cordova-lib.js
...

This should be fixed.

Command or Code

cordova prepare android

Environment, Platform, Device

macOS 15.2
MacBook Pro 2019 13"
ZSH

Version information

Cordova CLI: 12.0.0 ([email protected])
cordova-Android: 13.0.0

@dpogue
Copy link
Member

dpogue commented Dec 30, 2024

I believe this was fixed in cordova-cli in apache/cordova-cli#640

@GitToTheHub
Copy link
Author

Hi, yes it looks that it is fixed by this pr. So I have to what for a new release of the cli. Do you know, when this will be released? Thanks and regards.

@dpogue
Copy link
Member

dpogue commented Dec 31, 2024

Do you know, when this will be released?

Can't make any promises about release dates or timelines, since Apache Cordova is maintained by volunteers. It will depend on when someone has time and capacity to start the release process. Lately the focus has been on other things like the next major version for the iOS platform.

@GitToTheHub
Copy link
Author

Thank you, I understand and it is clear to me. Now I know this issue and know, there will be a fix in the future :)

Regards, Manuel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants