yarn install --check-files 给了我我不明白的错误输出

问题描述

我有一个 Ruby on Rails 项目,我正在新设置的服务器上部署该项目。

我运行命令 rails s -b 0.0.0.0,它说:

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

所以我运行了它告诉我运行的命令,最终它失败了,出现了一些我不太理解的错误

  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(),(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

我看了好几遍,我真的不知道它是什么意思。这个项目在我的开发虚拟机上运行良好。

任何帮助将不胜感激,谢谢。

解决方法

好像是nodeJS版本的问题。

我尝试了 node v15,它对我有用,而 v16 会失败。

此外,不推荐使用 node-sass。您应该更改要使用的另一个库。

,

更新:this 是为我和 @S.Goswami 解决的问题。请先尝试该解决方案。

如果上述解决方案不起作用,可能值得尝试推荐的 here,但不幸的是,这对我或 others 不起作用,但它可能值得如果上述解决方案不起作用,请尝试。以下是适用于某些人但并非所有人的解决方案的概述:

  1. 删除yarn.lock
  2. 在 Rails 应用的根目录中有一个名为 node_modules 的目录 - 删除它。注意:如果您使用 sublime 文本,它不会显示简单的目录 "house source control information and various binary output files"(经验教训)。在查找器中打开您的应用,找到yourapp/node_modules/并将其删除。
  3. 运行 spring stop(我不需要这样做,但其他人已经推荐了它,它不会受到伤害)。
  4. 现在只需使用 yarn install 重新安装您的节点模块。 但是,如果此步骤出错,请尝试使用 comments 和 @Scheff 的 answer
  5. 帮助中的 yarn install -std=c++17
,

node-sass 尚不支持 Node v16。所以现在将 Node 降级到 v15 将修复这些错误。如需进一步更新,请访问 sass/node-sass#3077