[FOLIO-3323] Latest Nodejs LTS (v16) breaks 'yarn install' in platform-complete Created: 26/Oct/21  Updated: 30/Nov/21  Resolved: 01/Nov/21

Status: Closed
Project: FOLIO
Components: None
Affects versions: None
Fix versions: None

Type: Bug Priority: TBD
Reporter: John Malconian Assignee: John Malconian
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original estimate: Not Specified

Issue links:
Relates
relates to MODGQL-142 Update node.js version from 10 to 14 Closed
relates to FOLIO-3324 Pin to node 14 for release builds Closed
Sprint: DevOps Sprint 126
Development Team: FOLIO DevOps

 Description   

Nodejs v16 became the "active" LTS of Nodejs today (previously it was v14) and resulting in sharp and node-gyp build errors when running 'yarn install' in platform-complete.



 Comments   
Comment by John Malconian [ 26/Oct/21 ]

Error looks something like:

"error /etc/folio/stripes/node_modules/sharp: Command failed.", "Exit code: 1", "Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)", "Arguments: ", "Directory: /etc/folio/stripes/node_modules/sharp", "Output:", "info sharp Using cached /root/.npm/_libvips/libvips-8.8.1-linux-x64.tar.gz", "prebuild-install WARN install No prebuilt binaries found (target=16.13.0 runtime=node arch=x64 libc= platform=linux)", "gyp info it worked if it ends with ok", "gyp info using node-gyp@8.2.0", "gyp info using node@16.13.0 | linux | x64", "gyp info find Python using Python version 3.8.10 found at \"/usr/bin/python3\"", "gyp info spawn /usr/bin/python3", "gyp info spawn args [", "gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',", "gyp info spawn args   'binding.gyp',", "gyp info spawn args   '-f',", "gyp info spawn args   'make',", "gyp info spawn args   '-I',", "gyp info spawn args   '/etc/folio/stripes/node_modules/sharp/build/config.gypi',", "gyp info spawn args   '-I',", "gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',", "gyp info spawn args   '-I',", "gyp info spawn args   '/root/.cache/node-gyp/16.13.0/include/node/common.gypi',", "gyp info spawn args   '-Dlibrary=shared_library',", "gyp info spawn args   '-Dvisibility=default',", "gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.13.0',", "gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',", "gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.13.0/<(target_arch)/node.lib',", "gyp info spawn args   '-Dmodule_root_dir=/etc/folio/stripes/node_modules/sharp',", "gyp info spawn args   '-Dnode_engine=v8',", "gyp info spawn args   '--depth=.',", "gyp info spawn args   '--no-parallel',", "gyp info spawn args   '--generator-output',", "gyp info spawn args   'build',", "gyp info spawn args   '-Goutput_dir=.'", "gyp info spawn args ]", "gyp info spawn make", "gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]", "<command-line>: warning: \"_GLIBCXX_USE_CXX11_ABI\" redefined", "<command-line>: note: this is the location of the previous definition", "In file included from /root/.cache/node-gyp/16.13.0/include/node/v8.h:30,", "                 from /root/.cache/node-gyp/16.13.0/include/node/node.h:63,", "                 from ../src/common.cc:22:", "/root/.cache/node-gyp/16.13.0/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:", "/root/.cache/node-gyp/16.13.0/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?", "  492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);", "      |                                      ^~~~~~~~~~~", "      |                                      remove_cv", "/root/.cache/node-gyp/16.13.0/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?", "  492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);", "      |                                      ^~~~~~~~~~~", "      |                                      remove_cv", "/root/.cache/node-gyp/16.13.0/include/node/v8-internal.h:492:50: error: template argument 2 is invalid", "  492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);", "      |                                                  ^", "/root/.cache/node-gyp/16.13.0/include/node/v8-internal.h:492:63: error: ‘::Perform’ has not been declared", "  492 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);", "      |                                                               ^~~~~~~", "make: Entering directory '/etc/folio/stripes/node_modules/sharp/build'", "  TOUCH Release/obj.target/libvips-cpp.stamp", "  CXX(target) Release/obj.target/sharp/src/common.o", "make: *** [sharp.target.mk:139: Release/obj.target/sharp/src/common.o] Error 1", "make: Leaving directory '/etc/folio/stripes/node_modules/sharp/build'", "gyp ERR! build error ", "gyp ERR! stack Error: `make` failed with exit code: 2", "gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)", "gyp ERR! stack     at ChildProcess.emit (node:events:390:28)", "gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)", "gyp ERR! System Linux 5.11.0-1020-aws", "gyp ERR! command \"/usr/local/bin/node\" \"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"rebuild\"", "gyp ERR! cwd /etc/folio/stripes/node_modules/sharp", "gyp ERR! node -v v16.13.0", "gyp ERR! node-gyp -v v8.2.0", "gyp ERR! not ok"]
Comment by John Malconian [ 26/Oct/21 ]

the 'stripes-build' folio-ansible role uses the 'n' npm dependency to set nodejs to the active lts version. e.g 'n lts'. I've changed this explicitly use v14 instead. This resolves the issue when using folio-ansible to build stripes. Jenkins CI and Github Actions currently use Nodejs v12. I feel like this is only part of the solution, however. Some members of the FOLIO community will no doubt be using v16 when attempting to build stripes from platform-complete and will likely run into the same problem. Zak Burke mentioned that setting the environment variable CXXFLAGS="-std=c++17" resolves the issue on OS X. This probably warrants verification on linux platforms and maybe should be noted in the platform-complete documentation.

Comment by Zak Burke [ 26/Oct/21 ]

Jason Skomorowski had the same problem on Linux and found the same fix, exporting CXXFLAGS, works there too. Also, I did not figure this out myself; I found a related post on stackoverflow.

Comment by jroot [ 28/Oct/21 ]

I'm hitting this problem as well, with building Stripes for Juniper HF3. Any good suggestions on pinning the version in the Dockerfile?

Comment by jroot [ 28/Oct/21 ]

To get around this, I am pinning the version of n to 14 in our Stripes Dockerfile.

Comment by John Malconian [ 01/Nov/21 ]

For clarification and posterity, it appears that the npm dependency sharp-libvips 8.8.1 (released in 2019) is not compatible with Nodejs v16. Subsequent releases of this dependency probably are compatible. I've updated the READMEs on the master and R2-2021 releases branches of platform-complete with the CXXFLAGS="-std=c++17" workaround. Closing.

Generated at Thu Feb 08 23:27:15 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d.