6

I have a Ruby on Rails project that I'm deploying on a freshly set up server.

I run the command rails s -b 0.0.0.0 and it says:

========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================

So I run the command it tells me to run, and ultimately it fails with a few errors that I don't really understand:

  g++ '-DNODE_GYP_MODULE_NAME=binding' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' -I/home/ubuntu/.node-gyp/16.0.0/include/node -I/home/ubuntu/.node-gyp/16.0.0/src -I/home/ubuntu/.node-gyp/16.0.0/deps/openssl/config -I/home/ubuntu/.node-gyp/16.0.0/deps/openssl/openssl/include -I/home/ubuntu/.node-gyp/16.0.0/deps/uv/include -I/home/ubuntu/.node-gyp/16.0.0/deps/zlib -I/home/ubuntu/.node-gyp/16.0.0/deps/v8/include -I../../nan -I../src/libsass/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++1y -std=c++0x -MMD -MF ./Release/.deps/Release/obj.target/binding/src/binding.o.d.raw   -c -o Release/obj.target/binding/src/binding.o ../src/binding.cpp
In file included from /home/ubuntu/.node-gyp/16.0.0/include/node/v8.h:30,
                 from /home/ubuntu/.node-gyp/16.0.0/include/node/node.h:63,
                 from ../../nan/nan.h:56,
                 from ../src/binding.cpp:1:
/home/ubuntu/.node-gyp/16.0.0/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
/home/ubuntu/.node-gyp/16.0.0/include/node/v8-internal.h:452:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
  452 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
      |                                      ^~~~~~~~~~~
      |                                      remove_cv
/home/ubuntu/.node-gyp/16.0.0/include/node/v8-internal.h:452:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
  452 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
      |                                      ^~~~~~~~~~~
      |                                      remove_cv
/home/ubuntu/.node-gyp/16.0.0/include/node/v8-internal.h:452:50: error: template argument 2 is invalid
  452 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
      |                                                  ^
/home/ubuntu/.node-gyp/16.0.0/include/node/v8-internal.h:452:63: error: ‘::Perform’ has not been declared
  452 |             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
      |                                                               ^~~~~~~
../src/binding.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE render(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/binding.cpp:284:98: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  284 |     int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
      |                                                                                                  ^~~~~~~~~~~~
../src/binding.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE render_file(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/binding.cpp:320:98: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  320 |     int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
      |                                                                                                  ^~~~~~~~~~~~
In file included from ../../nan/nan.h:56,
                 from ../src/binding.cpp:1:
../src/binding.cpp: At global scope:
/home/ubuntu/.node-gyp/16.0.0/include/node/node.h:806:43: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
  806 |       (node::addon_register_func) (regfunc),                          \
      |                                           ^
/home/ubuntu/.node-gyp/16.0.0/include/node/node.h:840:3: note: in expansion of macro ‘NODE_MODULE_X’
  840 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/binding.cpp:358:1: note: in expansion of macro ‘NODE_MODULE’
  358 | NODE_MODULE(binding, RegisterModule);
      | ^~~~~~~~~~~
make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/ubuntu/vendsmartsolutions/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Linux 5.4.0-1038-aws
gyp ERR! command "/home/ubuntu/.nvm/versions/node/v16.0.0/bin/node" "/home/ubuntu/vendsmartsolutions/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/ubuntu/vendsmartsolutions/node_modules/node-sass
gyp ERR! node -v v16.0.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
make: Leaving directory '/home/ubuntu/vendsmartsolutions/node_modules/node-sass/build'
Build failed with error code: 1

I looked it over several times and I really have no idea what any of it means. This project runs fine on my development VM.

Any help would be appreciated, thanks.

Blaine Lafreniere
  • 3,451
  • 6
  • 33
  • 55

3 Answers3

6

It seems like the problem with the version of nodeJS.

I tried node v15 and it works for me, while v16 would fail.

Also, node-sass is deprecated. You should change another library to use.

LuckyWind_sck
  • 61
  • 1
  • 2
4

UPDATE: this is what solved for me and @S.Goswami. Please try that solution first.

If the above solution doesn't work, it might be worth trying what is recommended here, but unfortunately that didn't work for me, or for others, but it could be worth a try if the above solution doesn't work. Here's an outline of the solution that worked for some, but not everyone:

  1. Delete yarn.lock
  2. There's a directory in the root of your rails app called node_modules - delete it. NOTE: if you use sublime text, it won't show directories that simply "house source control information and various binary output files" (lesson learned). Open your app in finder, find yourapp/node_modules/ and delete it.
  3. Run spring stop (I didn't need to do this, but others have recommended it, and it won't hurt).
  4. Now simply reinstall your node modules with yarn install. But, if this step errors, try using yarn install -std=c++17 as found in the help from the comments and @Scheff's answer
stevec
  • 41,291
  • 27
  • 223
  • 311
  • Unfortunately that didn't work with Archlinux's node while trying to install node modules for Ruby on Rails. – 15 Volts May 29 '21 at 00:59
  • @S.Goswami can you try [these](https://stackoverflow.com/a/67242989/5783745) instructions instead (I will update the above answer as I now know a lot more about the issue than I did back then) – stevec May 29 '21 at 01:01
  • @S.Goswami please let me know how you go. – stevec May 29 '21 at 01:07
  • Downgrade isn't an option for a lot of people. There are whole lot of soname bumps, and if I downgrade, I get: `node: error while loading shared libraries: libicui18n.so.68: cannot open shared object file: No such file or directory`. Sure, I can copy current libicui18n , rename and paste it in /lib/ and maybe some other dozen of them and make it running, but not a good idea. Definitely nvm is the only option imo. – 15 Volts May 29 '21 at 01:12
  • 1
    @S.Goswami the linked solution uses NVM so I think it should take care of that? – stevec May 29 '21 at 01:26
  • 1
    Yes, with NVM installed node v15, and it worked flawlessly! – 15 Volts May 29 '21 at 03:05
  • 1
    @S.Goswami brilliant! thanks for the update. I'll make it very obvious in this answer that it worked! – stevec May 29 '21 at 03:06
2

node-sass doesn't support Node v16 yet. So for now downgrade Node to v15 will fix these errors. For further updates visit sass/node-sass#3077

Zeeshan Ali
  • 254
  • 2
  • 7