[BUG] CLI fails if there's a package.json at the root
Description
We have a monorepo here with multiple plugins. I was trying to do better and create a top-level package.json and discovered the start multiple plugins command fails for some reason:
twilio flex:plugins:start --name plugin-sample -l debug
If I delete the topmost package.json everything works again.
Versions
| package | version |
|---|---|
@twilio/plugin-flex |
4.2.2 |
node |
14.15.1 |
Steps to Reproduce
Please provide the steps to reproduce this bug:
- Create a folder
- Create a plugin inside the folder
- Create a random package.json inside the folder
- Try to run
twilio flex:plugins:start --name plugin-livance-flex-authenticator -l debug - Delete the package.json -> Everything works again.
Expected Behavior
My flex instance and multiple plugins load.
Additional Context
I get the following error when trying to load.
[DEBUG] Cannot read property '@twilio/flex-ui' of undefined
[DEBUG] TypeError: Cannot read property '@twilio/flex-ui' of undefined
at Object.isPluginDir (C:\Users\lucas\.twilio-cli\node_modules\flex-dev-utils\dist\fs.js:768:44)
at C:\Users\lucas\.twilio-cli\node_modules\flex-plugin-scripts\dist\scripts\pre-script-check.js:236:31
at step (C:\Users\lucas\.twilio-cli\node_modules\flex-plugin-scripts\dist\scripts\pre-script-check.js:33:23)
at Object.next (C:\Users\lucas\.twilio-cli\node_modules\flex-plugin-scripts\dist\scripts\pre-script-check.js:14:53)
at C:\Users\lucas\.twilio-cli\node_modules\flex-plugin-scripts\dist\scripts\pre-script-check.js:8:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\lucas\.twilio-cli\node_modules\flex-plugin-scripts\dist\scripts\pre-script-check.js:4:12)
at Object.preScriptCheck [as default] (C:\Users\lucas\.twilio-cli\node_modules\flex-plugin-scripts\dist\scripts\pre-script-check.js:225:12)
at FlexPluginsStart.runScript (C:\Users\lucas\.twilio-cli\node_modules\@twilio-labs\plugin-flex\dist\sub-commands\flex-plugin.js:344:95)
at FlexPluginsStart.checkPlugin (C:\Users\lucas\.twilio-cli\node_modules\@twilio-labs\plugin-flex\dist\commands\flex\plugins\start.js:109:20)
@lucasmpr When you run the start command in a folder that has a package.json, the CLI assumes that you are running it in a local plugin directory and tries to load that plugin, which is the reason why you are seeing this error. This is expected behavior since the start command enables loading plugins in these ways
- When you run it in a local plugin directory, it automatically loads the plugin without you having to explicitly pass its name every time via the --name parameter.
- When you run it outside of a plugin directory, you can now use --name to pass in the names of the plugins you want to load.
Sure, but as I specified a name, shouldn't it search there first?
I agree with @lucasmpr, when a name is provided it should look for the name first. Or at least check if the name in the root is the same or not and then look for it in a sub directory.
Using @twilio/plugin-flex v5.0.6 and this issue is still present. 😞
The irony of this is that Twilio is using a monorepo for this project, but their tool does not support monorepos.
Hello Can Someone Help me i getting error while i hit the command "twilio flex:plugins:start" it's show an error, i can't understand the error...

Hi,
This is a long open item more than a year now, hence closing it. Feel free to reopen it if still required.