material-components / material-components-web-codelabs

Codelabs for Material Components for Web (MDC Web)
MIT License
130 stars 101 forks source link

Npm install not working even after downgrading to Node v14 for fibers compatibility #383

Open robml opened 2 years ago

robml commented 2 years ago

Here is the output from running npm install

I am by no means an expert and would appreciate any feedback, trying to follow the MDC 101 tutorial.

> fibers@4.0.1 install /home/robmel/edu/material_io/material-components-web-codelabs/mdc-101/starter/node_modules/fibers
> node build.js || nodejs build.js

make: Entering directory '/home/robmel/edu/material_io/material-components-web-codelabs/mdc-101/starter/node_modules/fibers/build'
  CXX(target) Release/obj.target/fibers/src/fibers.o
../src/fibers.cc: In function ‘void uni::SetAccessor(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::String>, uni::FunctionType (*)(v8::Local<v8::String>, const GetterCallbackInfo&), void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const SetterCallbackInfo&))’:
../src/fibers.cc:362:87: warning: cast between incompatible function types from ‘uni::FunctionType (*)(v8::Local<v8::String>, const GetterCallbackInfo&)’ {aka ‘void (*)(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>&)’} to ‘v8::AccessorNameGetterCallback’ {aka ‘void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&)’} [-Wcast-function-type]
  362 | ate->GetCurrentContext(), name, (AccessorNameGetterCallback)getter, (AccessorNameSetterCallback)setter).ToChecked();
      |                                                             ^~~~~~

../src/fibers.cc:362:123: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const SetterCallbackInfo&)’ {aka ‘void (*)(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&)’} to ‘v8::AccessorNameSetterCallback’ {aka ‘void (*)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&)’} [-Wcast-function-type]
  362 | essorNameGetterCallback)getter, (AccessorNameSetterCallback)setter).ToChecked();
      |                                                             ^~~~~~

../src/fibers.cc: In static member function ‘static void Fiber::Init(v8::Local<v8::Object>)’:
../src/fibers.cc:899:32: error: no matching function for call to ‘v8::Object::Set(v8::Local<v8::String>&, v8::Local<v8::Function>&)’
  899 |    target->Set(sym_yield, yield);
      |                                ^
In file included from /home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:67,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3670:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’
 3670 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3670:37: note:   candidate expects 3 arguments, 2 provided
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3673:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’
 3673 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
      |                                     ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3673:37: note:   candidate expects 3 arguments, 2 provided
../src/fibers.cc:903:28: error: no matching function for call to ‘v8::Function::Set(v8::Local<v8::String>&, v8::Local<v8::Function>&)’
  903 |    fn->Set(sym_yield, yield);
      |                            ^
In file included from /home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:67,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3670:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’
 3670 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3670:37: note:   candidate expects 3 arguments, 2 provided
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3673:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’
 3673 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
      |                                     ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3673:37: note:   candidate expects 3 arguments, 2 provided
../src/fibers.cc:909:58: error: no matching function for call to ‘v8::Object::Set(v8::Local<v8::String>, v8::Local<v8::Function>&)’
  909 |    target->Set(uni::NewLatin1Symbol(isolate, "Fiber"), fn);
      |                                                          ^
In file included from /home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:67,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3670:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)’
 3670 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
      |                                     ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3670:37: note:   candidate expects 3 arguments, 2 provided
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3673:37: note: candidate: ‘v8::Maybe<bool> v8::Object::Set(v8::Local<v8::Context>, uint32_t, v8::Local<v8::Value>)’
 3673 |   V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
      |                                     ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3673:37: note:   candidate expects 3 arguments, 2 provided
../src/fibers.cc: In function ‘void init(v8::Local<v8::Object>)’:
../src/fibers.cc:927:69: error: no matching function for call to ‘v8::Object::Get(v8::Local<v8::String>)’
  927 | _init || !target->Get(uni::NewLatin1Symbol(isolate, "Fiber"))->IsUndefined()) {
      |                                                             ^

In file included from /home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:67,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3717:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, v8::Local<v8::Value>)’
 3717 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3717:43: note:   candidate expects 2 arguments, 1 provided
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3720:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, uint32_t)’
 3720 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
      |                                           ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:3720:43: note:   candidate expects 2 arguments, 1 provided
In file included from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
../src/fibers.cc: At global scope:
/home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:793:43: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to
node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
  793 |       (node::addon_register_func) (regfunc),                          \
      |                                           ^
/home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:827:3: note: in expansion of macro ‘NODE_MODULE_X’
  827 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/fibers.cc:940:1: note: in expansion of macro ‘NODE_MODULE’
  940 | NODE_MODULE(fibers, init)
      | ^~~~~~~~~~~
../src/fibers.cc: In instantiation of ‘void uni::Return(v8::Persistent<T, v8::NonCopyablePersistentTraits<T> >&, uni::GetterCallbackInfo) [with T = v8::Object; uni::GetterCallbackInfo = v8::PropertyCallbackInfo<v8::Value>]’:
../src/fibers.cc:838:45:   required from here
../src/fibers.cc:206:3: error: no matching function for call to ‘v8::ReturnValue<v8::Value>::Set(v8::Persistent<v8::Object>&)’
  206 |   info.GetReturnValue().Set(handle);
      |   ^~~~
In file included from /home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:67,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:4220:18: note: candidate: ‘template<class S> void v8::ReturnValue<T>::Set(const v8::Global<S>&) [with S = S; T = v8::Value]’
 4220 |   V8_INLINE void Set(const Global<S>& handle);
      |                  ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:4220:18: note:   template argument deduction/substitution failed:
../src/fibers.cc:206:3: note:   ‘v8::Persistent<v8::Object>’ is not derived from ‘const v8::Global<T>’
  206 |   info.GetReturnValue().Set(handle);
      |   ^~~~
In file included from /home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:67,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:4222:18: note: candidate: ‘template<class S> void v8::ReturnValue<T>::Set(const v8::TracedReferenceBase<S>&) [with S = S; T = v8::Value]’
 4222 |   V8_INLINE void Set(const TracedReferenceBase<S>& handle);
      |                  ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:4222:18: note:   template argument deduction/substitution failed:
../src/fibers.cc:206:3: note:   ‘v8::Persistent<v8::Object>’ is not derived from ‘const v8::TracedReferenceBase<T>’
  206 |   info.GetReturnValue().Set(handle);
      |   ^~~~
In file included from /home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:67,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:4224:18: note: candidate: ‘template<class S> void v8::ReturnValue<T>::Set(v8::Local<S>) [with S = S; T = v8::Value]’
 4224 |   V8_INLINE void Set(const Local<S> handle);
      |                  ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:4224:18: note:   template argument deduction/substitution failed:
../src/fibers.cc:206:3: note:   ‘v8::Persistent<v8::Object>’ is not derived from ‘v8::Local<T>’
  206 |   info.GetReturnValue().Set(handle);
      |   ^~~~
In file included from /home/robmel/.cache/node-gyp/14.19.0/include/node/node.h:67,
                 from ../src/coroutine.h:1,
                 from ../src/fibers.cc:1:
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:11161:6: note: candidate: ‘void v8::ReturnValue<T>::Set(bool) [with T = v8::Value]’
11161 | void ReturnValue<T>::Set(bool value) {
      |      ^~~~~~~~~~~~~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:11161:31: note:   no known conversion for argument 1 from ‘v8::Persistent<v8::Object>’ to ‘bool’
11161 | void ReturnValue<T>::Set(bool value) {
      |                          ~~~~~^~~~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:11132:6: note: candidate: ‘void v8::ReturnValue<T>::Set(double) [with T = v8::Value]’
11132 | void ReturnValue<T>::Set(double i) {
      |      ^~~~~~~~~~~~~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:11132:33: note:   no known conversion for argument 1 from ‘v8::Persistent<v8::Object>’ to ‘double’
11132 | void ReturnValue<T>::Set(double i) {
      |                          ~~~~~~~^
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:11138:6: note: candidate: ‘void v8::ReturnValue<T>::Set(int32_t) [with T = v8::Value; int32_t = int]’
11138 | void ReturnValue<T>::Set(int32_t i) {
      |      ^~~~~~~~~~~~~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:11138:34: note:   no known conversion for argument 1 from ‘v8::Persistent<v8::Object>’ to ‘int32_t’ {aka ‘int’}
11138 | void ReturnValue<T>::Set(int32_t i) {
      |                          ~~~~~~~~^
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:11149:6: note: candidate: ‘void v8::ReturnValue<T>::Set(uint32_t) [with T = v8::Value; uint32_t = unsigned int]’
11149 | void ReturnValue<T>::Set(uint32_t i) {
      |      ^~~~~~~~~~~~~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:11149:35: note:   no known conversion for argument 1 from ‘v8::Persistent<v8::Object>’ to ‘uint32_t’ {aka ‘unsigned int’}
11149 | void ReturnValue<T>::Set(uint32_t i) {
      |                          ~~~~~~~~~^
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:4239:18: note: candidate: ‘template<class S> void v8::ReturnValue<T>::Set(S*) [with S = S; T = v8::Value]’
 4239 |   V8_INLINE void Set(S* whatever);
      |                  ^~~
/home/robmel/.cache/node-gyp/14.19.0/include/node/v8.h:4239:18: note:   template argument deduction/substitution failed:
../src/fibers.cc:206:3: note:   mismatched types ‘S*’ and ‘v8::Persistent<v8::Object>’
  206 |   info.GetReturnValue().Set(handle);
      |   ^~~~
make: *** [fibers.target.mk:120: Release/obj.target/fibers/src/fibers.o] Error 1
make: Leaving directory '/home/robmel/edu/material_io/material-components-web-codelabs/mdc-101/starter/node_modules/fibers/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/robmel/.nvm/versions/node/v14.19.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
gyp ERR! System Linux 5.4.72-microsoft-standard-WSL2
gyp ERR! command "/home/robmel/.nvm/versions/node/v14.19.0/bin/node" "/home/robmel/.nvm/versions/node/v14.19.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /home/robmel/edu/material_io/material-components-web-codelabs/mdc-101/starter/node_modules/fibers
gyp ERR! node -v v14.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
RHEL users please run: `yum install gcc-c++` and `yum groupinstall 'Development Tools'`
Alpine users please run: `sudo apk add python make g++`
sh: 1: nodejs: not found
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! fibers@4.0.1 install: `node build.js || nodejs build.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the fibers@4.0.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/robmel/.npm/_logs/2022-03-10T20_14_53_947Z-debug.log

Note: running npm audit fix hasn't changed anything.

DazWilkin commented 2 years ago

I'm not an expert either but I encountered an issue similar to yours.

It's unfortunate that these issues appear to be languishing.

So, I spent (probably too long) this afternoon Googling around for solutions and appear to have been successful using n:

  1. I'm using Google Cloud Shell as I don't want to install Node.js and npm on my host.
  2. Installed n (npm install -g n) and am using N_PREFIX (i.e. mkdir ${HOME}/.n && export N_PREFIX=${HOME}/.n)
  3. Remove package-lock.json and node_modules
  4. Installed (a non-16.x Node.js) with n use 15.14.0
  5. I was expecting this to change node --version but it didn't
  6. n exec 15.14.0 npm install then n exec 15.14.0 npm start

And I'm able to browse the Shrine app.

I hope that helps others!

It would be good if the repo owners were to (please!) update the documentation to reflect the apparent issue with the codelabs' use of fibers and Node.js v16.x