react-pdf: Using react-pdf in a lambda fails to install

OS: Linux 4.9.85-38.58.amzn1.x86_64 React-pdf version: 0.7.6 Description: Does anyone know how to run react-pdf in a lambda? I’m trying to install it(yarn add @react-pdf/core) but I get the following error:

yarn add v1.6.0 [1/5] Validating package.json… [2/5] Resolving packages… [3/5] Fetching packages… [4/5] Linking dependencies… [5/5] Building fresh packages… [1/1] ⠈ yoga-layout: NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR [-/1] ⠈ waiting… [-/1] ⠈ waiting… [-/1] ⠈ waiting… error /home/ec2-user/environment/Commerce/node_modules/yoga-layout: Command failed. Exit code: 1 Command: npm run build:node Arguments: Directory: /home/ec2-user/environment/Commerce/node_modules/yoga-layout Output:

yoga-layout@1.9.3 build:node /home/ec2-user/environment/Commerce/node_modules/yoga-layout npm run copy-sources && autogypi && node-gyp configure build

yoga-layout@1.9.3 copy-sources /home/ec2-user/environment/Commerce/node_modules/yoga-layout ! npm -s run is-monolithic || (rsync -r --checksum --delete …/yoga/ sources/yoga/)

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR make: Entering directory /home/ec2-user/environment/Commerce/node_modules/yoga-layout/build' COPY Release/obj.target/nbind/geni/symbols.txt CXX(target) Release/obj.target/nbind/sources/yoga/Utils.o g++: error: unrecognized command line option ‘-std=c++14’ make: *** [Release/obj.target/nbind/sources/yoga/Utils.o] Error 1 make: Leaving directory /home/ec2-user/environment/Commerce/node_modules/yoga-layout/build’ gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/home/ec2-user/.nvm/versions/node/v8.10.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23) gyp ERR! stack at emitTwo (events.js:126:13) gyp ERR! stack at ChildProcess.emit (events.js:214:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12) gyp ERR! System Linux 4.9.85-38.58.amzn1.x86_64 gyp ERR! command “/home/ec2-user/.nvm/versions/node/v8.10.0/bin/node” “/home/ec2-user/.nvm/versions/node/v8.10.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “configure” “build” gyp ERR! cwd /home/ec2-user/environment/Commerce/node_modules/yoga-layout gyp ERR! node -v v8.10.0 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! yoga-layout@1.9.3 build:node: npm run copy-sources && autogypi && node-gyp configure build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the yoga-layout@1.9.3 build:node script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 25 (15 by maintainers)

Most upvoted comments

I think the cause of error is building yoga every time the package gets installed. I thought that by using yoga-dom this may get fixed.

Pros

  • Not building yoga every time
  • Using webassembly instead of asm.js. Not sure is this is actually an advantage in performance though.
  • At first sight it may also mean a a smaller bundle size

Cons

  • Not using original package, probably meaning slower upgrades
  • I recently opened an issue on yoga repo to include react-pdf in their landing. Probably they will ignore it, but if we do this for sure they will [See #303]
  • Yoga-dom exports a promise, so there’s some code changes needed in order to use it as we are currently using Yoga

Thoughts?

@ferdinandsalis were you actually able to get this working? I have been able to compile yoga-layout with a newer version of GCC but it doesn’t seem to matter because it still relies on a newer version of libstdc++.so.6 which isn’t available in the lambda environment and I don’t see how I could make changes to the lambda environment so my compiled yoga-layout will run. Any additional details on how you got this working would be much appreciated.

When I try to import react-pdf I get the following error: /var/lang/lib/libstdc++.so.6: version `CXXABI_1.3.9’ not found (required by /var/task/node_modules/yoga-layout/build/Release/nbind.node)

@jbovenschen that’s funny I stumbled upon the same travis config and added the same to my circleci. It works now. Thanks.

If anyone has this issue, here are the commands to make yoga-layout compile for circleci:

dependencies:
  pre:
    - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
    - sudo apt-get update -qq
    - sudo apt-get install -qq g++-6
    - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90