Building Foreman 2.0.0 from source fails

Hi everyboy,
currently i trie to build foreman 2.0.0 on sles12sp5 from source, but it fails.

Problem:
To build foreman from source i’ve installed ruby2.5 and npm10 and all the other required packages as it’s described in Foreman :: Manual.
Afterwards i cloned the source code from git / with the command “git clone https://github.com/theforeman/foreman.git -b 2.0-stable” and run the other commands (cp config …, gem install bundler, bundle install --without mysql2 test --path vendor,…)
All commands could be executed without problems. Only the last command “RAILS_ENV=production bundle exec rake db:seed assets:precompile locale:pack webpack:compile” returned the following:

[./webpack/assets/javascripts/foreman_config_reports_modal_diff.js] ./webpack/assets/javascripts/foreman_config_reports_modal_diff.js 1.91 kB {0}
[./webpack/assets/javascripts/foreman_editor.js] ./webpack/assets/javascripts/foreman_editor.js 3.96 kB {0} [built]
[./webpack/assets/javascripts/foreman_hostgroups.js] ./webpack/assets/javascripts/foreman_hostgroups.js 1.29 kB {0} [built]
[./webpack/assets/javascripts/foreman_hosts.js] ./webpack/assets/javascripts/foreman_hosts.js 6.29 kB {0} [built]
   [4] multi react-intl intl 40 bytes {1} [built]
[./webpack/assets/javascripts/spice.js] ./webpack/assets/javascripts/spice.js 2.77 kB {0} [built]
[node_modules/react-intl/lib/index.es.js] ./node_modules/react-intl/lib/index.es.js + 1 modules 57.9 kB {1} [built]
    + 436 hidden modules

WARNING in ./webpack/assets/javascripts/react_app/common/I18n.js
118:49-59 Critical dependency: the request of a dependency is an expression
 @ ./webpack/assets/javascripts/react_app/common/I18n.js
 @ ./webpack/assets/javascripts/bundle.js

WARNING in ./webpack/assets/javascripts/react_app/common/I18n.js
74:49-59 Critical dependency: the request of a dependency is an expression
 @ ./webpack/assets/javascripts/react_app/common/I18n.js
 @ ./webpack/assets/javascripts/bundle.js
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js!node_modules/sass-loader/lib/loaripts/react_app/components/Pagination/pagination.scss:
       2 modules

As the error type was only a warning, I first ignored it. But after starting the apache, which is configured to start foreman through passenger (6.0.4), it only shows a blank / white page in chrome / firefox.
Starting the debugging console, i got three times the following error:

I18n.js:18 Uncaught (in promise) Error: Cannot find module "."
    at I18n.js:18
    at I18n.js:18

Distribution and version:
SLES12 SP5 with ruby2.5 and nodejs10/npm10 from build.opensuse.org - same problem occurs with nodejs12/npm12

Do you have any idea what’s wrong here? If you also need further data, please let me know.

best regards

Try this: https://github.com/theforeman/foreman/pull/7604

1 Like

Perfect, this fix solved my problem.
Tank you

Hi @mmoll,
it seems to be broken again :(. Yesterday it still worked, but not today.
I added

“babel-plugin-dynamic-import-node”: “2.3.0”,

to the package.json, but nonetheless npm installs the wrong package version. Do you have further recommendations for me?

…okay, also pinning the following packages in dev worked for me:

"@babel/preset-env": "7.9.0",
"@babel/plugin-transform-modules-amd": "7.9.0",
"@babel/plugin-transform-modules-commonjs": "7.9.0",
"@babel/plugin-transform-modules-systemjs": "7.9.0",

We just figured out the same on IRC while trying to debug CI failures today.
Looks like @babel/preset-env version 7.9.6 was released today which requires version 7.9.6 of the transform modules plugins that also pull in babel-plugin-dynamic-import-node 2.3.3.

This is in the support forum, but this is more of a developer thing. Don’t be afraid to post there, even if you don’t have commit access on the Foreman repos.