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

[Question] Build from Sources failed due to dependancy error #193

Open
akei1984 opened this issue Jan 6, 2025 · 10 comments
Open

[Question] Build from Sources failed due to dependancy error #193

akei1984 opened this issue Jan 6, 2025 · 10 comments
Assignees
Labels
Question Further information is requested

Comments

@akei1984
Copy link

akei1984 commented Jan 6, 2025

Describe the bug
I tried to build tbmq from sources using the Main and the 2.0.1 release branch using

mvn -T 0.8C clean install -DskipTests

But currently my build seams to fail with an incompatible dependancy.
grafik

Changing the Build Options to ignore the node-Engine (for now)
<configuration> <arguments>install --ignore-engines</arguments> </configuration>

Gets past the first error but running but in to the next one as
grafik

As the build process seams to. fail loading the additonal Angular Plugins:
grafik
(index -1)

Your Server Environment

  • OS MacOS Somona 14.6.1
  • Java 22
  • Yarn 1.22.17

My guess is that some Angular Versions are mixed in the packages.json but really not sure about that.

Any idea how to proceed?

@akei1984 akei1984 added the Question Further information is requested label Jan 6, 2025
@deaflynx
Copy link
Contributor

deaflynx commented Jan 6, 2025

Hi @akei1984

To fix the issue please update your node version. As it is mentioned in the error details that you sent you have node 16.15.1, but >=18 is required.

You may install new node version using for example nvm (Node Version Manager) with the following commands.

Use nvm to install Node.js version 18.19.0:
nvm install 18.19.0

Verify the installation:
node -v
(this should display: v18.19.0)

Set the installed version as the default:
nvm alias default 18.19.0

See the list of installed versions:
nvm list

Hope this helps.

@akei1984
Copy link
Author

akei1984 commented Jan 6, 2025

Hi @deaflynx thank you for the fast response.

if i understood the Projectstructure correctly the NodeJs version is definied in the pom.xml via a maven plugin.
image
i just changed it to 18.19.0
image
it fixes the inital issue but iam still running into the issue with the Angular plugins
image
image

[error] TypeError: Cannot read properties of undefined (reading 'pluginOptions')
    at module.exports (/Users/admin/IdeaProjects/tbmq/ui-ngx/extra-webpack.config.js:71:61)
    at CustomWebpackBuilder.<anonymous> (/Users/admin/IdeaProjects/tbmq/ui-ngx/node_modules/@angular-builders/custom-webpack/dist/custom-webpack-builder.js:32:50)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/admin/IdeaProjects/tbmq/ui-ngx/node_modules/@angular-builders/custom-webpack/dist/custom-webpack-builder.js:5:58)

Causing my build to fail.

@deaflynx
Copy link
Contributor

deaflynx commented Jan 6, 2025

It is hard to say at this moment what is the cause of this error, need more time to debug.
I see you have changes in the yarn.lock, can you please try to rollback them and run mvn clean install -DskipTests once again?

@akei1984
Copy link
Author

akei1984 commented Jan 6, 2025

Sure thing. i just did an rm -rf node_modules/ yarn.lock .angular to be sure they are rebuild next run in the root (tbmq) and ui-ngx project. After that a mvn clean install -DskipTests

image

Running the failed mvn goal manualy seams gave me the following error as before
image

I also did a quick check in the extra-webpack.config.js it seams this line:

  const index = config.plugins.findIndex(p => p instanceof ngWebpack.AngularWebpackPlugin); //is returning -1 ` an causing the error.
    let angularWebpackPlugin = config.plugins[index];
    if (config.mode === 'production') {
        const angularCompilerOptions = angularWebpackPlugin.pluginOptions; // will fail here as angularWebpackPlugin is not initialized correctly 

Maybe it helps

@deaflynx
Copy link
Contributor

deaflynx commented Jan 8, 2025

Hi @akei1984,

I still could not understand the root cause, but I think I have a fix. You are right that it fails because the index is -1 (it should be equal to 7) as it can not find such plugin by instance of ngWebpack.AngularWebpackPlugin. On my environment I got this error only when I changed the @ngtools/webpack version from 15.2.1 to 15.2.10.

Please try to replace the following line to find by the constructor.name:
const index = config.plugins.findIndex(p => p instanceof ngWebpack.AngularWebpackPlugin);
with:
const index = config.plugins.findIndex(p => p.constructor.name === 'AngularWebpackPlugin');

Please note that in the next releases we will use custom-esbuild instead of webpack.

@akei1984
Copy link
Author

akei1984 commented Jan 14, 2025

Hi @deaflynx Thank you for your support. i just did some testing again and it seams i can replicate the issue now that is happening.

  1. checkout branch "feature/ui/angular-optimization" (might work with others as as well that contain angular 18)
  2. build the branch
  3. check out main
  4. build will run successfully on main without modifications
  5. Clear the yarn caches (node_modules and .angular files) in the ui-ngx project (e.g rm -rf node_modules/ yarn.lock .angular )
  6. run the main build again and it will fail with a dependancy error.

This is happening as mvn clean is not removing the node_modules/ and .angular files by default i created a small PR that includes a maven plugin to drop these files automatically to prevent such wired behavior in the future. https://github.com/akei1984/tbmq/tree/improved-mvn-clean-for-nodemodules

However the build fails now but consistently :)

@deaflynx
Copy link
Contributor

Hi @akei1984,

Thank you for your efforts in this issue, detailed explanation and proposed solution. We will review your PR and discuss it further usage with the team.

Copy link

This issue has been marked as stale due to 7 days of inactivity. If no further activity occurs within the next day, it will be automatically closed.

@github-actions github-actions bot added the Stale Issue is stale for requested period label Jan 24, 2025
@dmytro-landiak
Copy link
Contributor

This is still in progress.

@dmytro-landiak dmytro-landiak removed the Stale Issue is stale for requested period label Jan 24, 2025
@deaflynx
Copy link
Contributor

Hi @akei1984,

Unfortunately, I could not understand the root cause of this error and why it fails to find the plugin. The only fix that worked for me when this error occurred was changing the following line in extra-webpack.config.js:
const index = config.plugins.findIndex(p => p instanceof ngWebpack.AngularWebpackPlugin);
with:
const index = config.plugins.findIndex(p => p.constructor.name === 'AngularWebpackPlugin');

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

No branches or pull requests

3 participants