• BLOG
  • Build Fail - Loading "imagemin.js" tasks...ERROR >> ReferenceError: primordials is not defined


    Attempting to build v10.1.RC3. Below are all the errors i recieve during build. The most significant being Loading “imagemin.js” tasks…ERROR

    How can this be resolved please?

    Many Thanks for any suggestions.

    System info:-
    npm -v = 8.5.1
    node -v= 12.22.9
    bower -v = 1.8.14
    gradle -v = Gradle 7.5.1

    Ubuntu 22.04.2 LTS
    Kotlin: 1.6.21
    Groovy: 3.0.10
    Ant: Apache Ant™ version 1.10.11 compiled on July 10 2021
    JVM: 17.0.7 (Oracle Corporation 17.0.7+8-LTS-224)
    OS: Linux 5.19.0-42-generic amd64

    Error 1) bower install =

    bower resolution Unsuitable resolution declared for jquery: 3.6.1

    Unable to find a suitable version for jquery, please choose one by typing one of the numbers below:
    1) jquery#>=1.8.0 <2.1.0 which resolved to 2.0.3 and is required by bootstrap#2.3.2
    2) jquery#>=1.8.0 which resolved to 3.7.0 and is required by ng-grid#2.0.14
    3) jquery#>=3.1.x which resolved to 3.7.0 and is required by angular-ui-sortable#0.19.0
    4) jquery#>=1.7.1 which resolved to 3.7.0 and is required by bootstrap-datepicker#1.3.1
    5) jquery#>=1.8.3 which resolved to 3.7.0 and is required by bootstrap-timepicker#0.2.7
    6) jquery#>=1.6 which resolved to 3.7.0 and is required by jquery-ui#1.12.1
    7) jquery#1.9.1 - 3 which resolved to 3.7.0 and is required by bootstrap#3.4.1

    Prefix the choice with ! to persist it to bower.json

    Error 2) gradle -v returns:-

    Registering “grunt-contrib-imagemin” local Npm module tasks.
    Reading /home/john/Documents/openspecimen/www/node_modules/grunt-contrib-imagemin/package.json…OK
    Parsing /home/john/Documents/openspecimen/www/node_modules/grunt-contrib-imagemin/package.json…OK
    Loading “imagemin.js” tasks…ERROR

    ReferenceError: primordials is not defined
    at fs.js:36:5
    at req_ (/home/john/Documents/openspecimen/www/node_modules/natives/index.js:143:24)
    at Object.req [as require] (/home/john/Documents/openspecimen/www/node_modules/natives/index.js:55:10)
    at Object. (/home/john/Documents/openspecimen/www/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
    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)
    at require (internal/modules/cjs/helpers.js:74:18)

    Error 3) gradle build

    Running “useminPrepare:html” (useminPrepare) task
    Configuration changed for concat, uglify, cssmin

    Running “concurrent:dist” (concurrent) task

    Loading "imagemin.js" tasks...ERROR
    >> ReferenceError: primordials is not defined
    Running "svgmin:dist" (svgmin) task
    Total saved: 0 B
        Warning: Loading "imagemin.js" tasks...ERROR
    >> ReferenceError: primordials is not defined
    Warning: Task "imagemin" not found. Use --force to continue.
    Aborted due to warnings. Use --force to continue.
        Aborted due to warnings.

    Task :grunt_build FAILED

    FAILURE: Build failed with an exception.

    • What went wrong:
      Execution failed for task ‘:grunt_build’.

    Process ‘command ‘grunt’’ finished with non-zero exit value 6

    • 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.

    BUILD FAILED in 2m 37s
    4 actionable tasks: 4 executed


    Further information which might help the developers.
    Downgraded JDK to version 8.
    The build environment has successfully built - openspecimen-7.2.RC2, openspecimen-7.2.RC3, openspecimen-8.0.RC7.

    Attempted openspecimen-8.1.RC8 and openspecimen-9.0.RC7
    A similar to the above ‘bower install’ error occurred, here for jquery 3.6.0:-

    Error on bower install =

    Build failed with =

    Hello @John_Miller,

    Please go inside $OPENSPECIMEN_HOME/ui/ dir.

    Rename the directory src_bk to src using the following command: mv src_bk src

    And rerun the command, and let us know if you face any issues.


    Hi @Kaustubh_Wadagavi

    This folder in all the source builds I have downloaded is already set as - ‘/ui/src’

    The main issues are the ones pointed out in my first message as it seems to be affecting a lot of user builds.

    Being:- ```
    Warning: Loading “imagemin.js” tasks…ERROR

    ReferenceError: primordials is not defined

    FAILURE: Build failed with an exception.
        What went wrong:
        Execution failed for task ‘:grunt_build’.
        Process ‘command ‘grunt’’ finished with non-zero exit value 6
    Best wishes,


    navigate into www/ directory in $OS_HOME
    	sudo npm cache clean
    	sudo npm i --save-dev grunt-contrib-imagemin
    	sudo npm install gifsicle@1.0.3
    	sudo npm install
    	bower install
    	grunt build

    All complete successfully.

    The final ‘gradle build’ command - still fails on this error - the folder is there and called ‘\ui\src’

    Best wishes,

    @John_Miller did you ever resolve the issue with the gradle deply command failing because to task ‘:vue_backup_src’ failed because it can’t start process command ‘mv’.

    I am having the same issue.


    No I didnt resolve this. Installed many different combinations of Node and Gradle. Each one gave errors.
    There were 3 main errors:-

    1. imagemin.js - primordials not defined.
    2. ‘mv’ command not recognised.
    3. An error to do with ANTLR plugin.

    Please let me know if you get past the error.

    I was able to get past the mv command error. In the build.gradle file around line 323 there are a couple of task functions that try to run some command line commands. they don’t seem to work for whatever versions of gradle and node.js I have tried. So I moved those commands they are trying to run into batch files and then called the batch file from within those task in the build.gradle file.

    This got me past a couple errors but I have now hit another one stating @vitejs/plugin-vue requires vue >= 3.2.13…

    If you are able to get past this error, let me know.

    Hope this helps

    ORIGINAL task function:
    task vue_backup_scr(type: Exec) {
    workingDir ‘./ui’
    commandLine ‘mv’, ‘src’, ‘src_bk’

    CHANGED task function:
    task vue_backup_scr(type: Exec) {
    commandLine ‘vue_backup_scr.bat’

    vue_src_backup.bat commands
    move c:\OpenSpecimen\ui\src c:\OpenSpecimen\ui\src_bk

    To all that are concerned

    Running “htmlmin:dist” (htmlmin) task
    Warning: dist/modules/administrative/job/search.html
    Error: Parse Error:
    <os-select os-md-input ng-model=“filterOpts.type” list=“types”
    select-prop=“type” display-prop=“caption” class=form-control"
    placeholder="{{‘jobs.type’ | translate}}">

      <os-clear-filters opts="filterOpts"></os-clear-filters>

    Use --force to continue.

    Aborted due to warnings.
    This actuallly seems to be an real error done by The Shagnis in 10.1.RC3

    The Build works …

    Trick17: You have to use node 12 for the angular part and node 14 For Vue.js. Install both and feed them the dependencies for the vue part (I think 14 will do in general but had errors with 14 before; Now the build runs)
    Trick 18: Some html files in the old app repo of anguilar js are actually broken → Real Syntax errors inc.

    You have to fix those they are in:


    The imagemin JS error you are getting btw is due to a bad dependency try to play arround wiht the grunt-contrib-imagemin version (package.json within the old angular js frontend)

    Yeah and well ofc there is no login page visible. If someone could give me a hint on where to enable it again :slight_smile: i would be grateful.


    @Kaustubh_Wadagavi @Simon_Streit

    Thank you for both of your inputs. I have been drawn in to other work and have not attempted to build the software since mid July.

    Here are the notes I made to fix the build up to the @vitejs/plugin-vue error:-

    —Ubuntu 22.4 needs libpng12 adding:- FIXED ISSUE
    You can either download the libpng12-0 deb from here or add the PPA:

    sudo add-apt-repository ppa:linuxuprising/libpng12
    sudo apt update
    sudo apt install libpng12-0

    —“Exit error 6 fix”:- FIXED ISSUE
    Since version 10 of Node there is a conflict. Add this to package.json file.
    “overrides”: {
    “graceful-fs”: “^4.2.11”

    “npm finsihed with error code 1 - ERROR Error: @vitejs/plugin-vue requires vue (>=3.2.13)”
    Unsupported engine - required: { node: ‘^14.18.0 || >=16.0.0’ },

    Hope to return to this work soon.

    @Simon_Streit have you managed to build a working version of v10.1.RC3 or newer ? Your last post said the login page didn’t load correctly.

    Is the community edition still being supported by Krishagni…

    The utter silence is somewhat concerning…

    Build Works 10.1.RC3 … Frontend Works . Krishagni does not have Bandwith for “free” support :slight_smile: .

    Dockerfile (3.5 KB)
    build.gradle (13.6 KB)
    bower.json (1.6 KB)
    Gruntfile.js (13.2 KB)

    Had to actually deactivate minify for the moment … and the image copy in the Gruntfile is still to fix.

    You can see all the Environment stuff in the Dockerfile
    The Build file just uses another Maven URL.

    There are Syntax errors in html. They introduced a New table and want to migrate an old one. That in case of a Fresh DB is empty so you need to kill this in the db xml Files.
    The solution here is still not good but it works mostly …
    The main Problem are bootstrap-timepicker → Which causes a JQuery Problem for me. And this in Turn can cause other Problems. Still you can probably fix the order in bower.json as I will (maybe) try next.

    Another big issue and the reason why i removed the minify is that the grunt Versions are needed by another second level dependency that is installed within bower (Please check yourself in bower components as i forgot.) Yeah and the image folder is missing in tomcat_dir/webapps/openspecimen :slight_smile: .

    So you can add it manually or just fix the Gruntfile. → Use ChatGPT for that it can explain everything needed to get it to run and hopefully will end this madness soon by being able to just do this tasks automatically :slight_smile: .

    Summing up this Works but there is some dependency juggling left to make it good.

    Have fun
    Best Simon

    1 Like