facebook / yoga

Yoga is an embeddable layout engine targeting web standards.

Home Page:https://yogalayout.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NPM build fails on Windows

nlieb opened this issue · comments

When installing with yarn on Windows the following is produced:

> yoga-layout@1.0.1 copy-sources C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout
> ! npm -- run is-monolithic || (rsync -r --checksum --delete ../yoga/ sources/yoga/)

'!' is not recognized as an internal or external command,
operable program or batch file.

Unfortunately bash is officially unsupported with npm on Windows, even when using cygwin or similar (see npm/npm#9420). When trying to manually build the following is produced, meaning the native build is also broken:

..\node_modules\node-gyp\bin\node-gyp.js" "configure" "build" "--asmjs=1" )  else (node "" "configure" "build" "--asmjs=1" )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  Copying ../nbind/dist/em-api.js to Release\obj\nbind\\em-api.js
          1 file(s) copied.
  Copying ../nbind/src/pre.js to Release\obj\nbind\\pre.js
          1 file(s) copied.
  Copying ../nbind/src/post.js to Release\obj\nbind\\post.js
          1 file(s) copied.
  YGNodeList.c
  Yoga.c
  Node.cc
  global.cc
  nbind.cc
  common.cc
..\..\nbind\src\common.cc(6): error C2871: 'nbind': a namespace with this name does not exist [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbi                                                                          nd.vcxproj]
..\..\nbind\src\common.cc(9): error C2653: 'nbind': is not a class or namespace name [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxpro                                                                          j]

Would building on Windows be possible in the future, or having a precompiled library included? It's currently preventing us from using the library as many of our developers use Windows.

Also, version 1.1.0 was not published to npm, not sure if that was intentional.

The js build is still a bit experimental, there's a few things that will have to be fixed in later iterations.

Can you try to manually edit the package.json file to replace:

"copy-sources": "! npm -s -- run is-monolithic || (rsync -r --checksum --delete ../yoga/ sources/yoga/)",

by (notice the extra :; at the beginning of the command)

"copy-sources": ":; ! npm -s -- run is-monolithic || (rsync -r --checksum --delete ../yoga/ sources/yoga/)",

? I think it should fix the issue.

@nwlieb Have you been able to test it?

That seems to have helped, though the following is still produced:

C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout>npm run build:browser

> yoga-layout@1.0.1 build:browser C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout
> npm -- run copy-sources && npm -- run node-gyp configure build --asmjs=1


> yoga-layout@1.0.1 copy-sources C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout
> :; ! npm -- run is-monolithic || (rsync -r --checksum --delete ../yoga/ sources/yoga/)


> yoga-layout@1.0.1 node-gyp C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout
> node-gyp "configure" "build" "--asmjs=1"


C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" "configure" "build" "--asmjs=1" )  else (node "" "configure" "build" "--asmjs=1" )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  Node.cc
  nbind.cc
  common.cc
  reflect.cc
..\..\nbind\src\common.cc(6): error C2871: 'nbind': a namespace with this name does not exist [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(9): error C2653: 'nbind': is not a class or namespace name [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(12): error C2653: 'Status': is not a class or namespace name [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(14): error C2653: 'NBind': is not a class or namespace name [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(14): error C2061: syntax error: identifier 'cbFunction' [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(15): error C3861: 'getClassList': identifier not found [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(15): error C3861: '<begin>': identifier not found [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(15): error C3312: no callable 'begin' function found for type 'unknown-type' [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(15): error C3861: '<end>': identifier not found [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(15): error C3312: no callable 'end' function found for type 'unknown-type' [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(16): error C2065: 'bindClass': undeclared identifier [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(18): error C2065: 'bindClass': undeclared identifier [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]
..\..\nbind\src\common.cc(18): error C2227: left of '->getName' must point to class/struct/union/generic type [C:\Users\User\Documents\experiment-flex\node_modules\yoga-layout\build\nbind.vcxproj]

...With many more errors afterwards.

PS sorry for the delay -- it's been really busy lately.

@nwlieb did you figure out any temporary work around to get this library working on windows.
I did try @arcanis/npm-git-install solution, but ended into similar errors again.

Unfortunately no, since the compilation error comes from a library we use rather than our code. As a workaround, I suggest you take a look at the linux subsystem for Windows - I know that it works really well in the insider previews.

i had worked around this problem by importing yoga-layout in Bash on ubuntu on Windows

Prerequisites
Your PC must be running a 64-bit version of Windows 10

Step 1: Activate Ubuntu shell on windows
Step 2: Access ubuntu-bash files from windows
Step 3: (only if you run into nbind errors) npm install nbind

If building on windows isn't support, I really hope you'll find a way to provide the precompiled javascript libs separately so developers can install from npm on any machine.
something like npm install yoga-layout-js would be perfect!

At this point it's going to take me a heck of a lot of work to get an environment set up that will allow me to even pull down the npm build, just so I can grab the asm files and then add them to my project manually since npm won't install things on win7 due to these errors.

So now that I've got things working in my project, I still can't add the dependency to package.json since that precludes me from ever being able to do a npm install (since install runs the build scripts for the other platforms causing these errors in windows). I can add the single package with npm install yoga-layout --ignore-scripts so it will at least pull things down, and everything works after that, but I don't know of a way to always ignore the scripts for ONLY this package; globally isn't acceptable.

So since I'm only trying to pull in the js libs, can anyone think of any good ways to add a flag to NOT run the build scripts for other platforms?

Suggestion: adding an config prop for the desired platform into the npmrc config and then having the build scripts depend on that?

hmm @chrisregnier I just tried npm config set yoga-layout:platform standalone and npm install yoga-layout still fails.

I don't think the latest has been published yet

so I just tried to do an install directly from the yoga/javascript folder with the different platforms set and I see it failing as well. Looks like more non-windows friendly commands in the 'copy-sources' script.

The code I added in works correctly (it just forwards to the proper script based on platform). I didn't do anything so the actual scripts work on windows though. I've actually got 'none' set as my platform specifically so that it doesn't run the build scripts, which aren't needed for installing the lib as an external dep.

This issue should be re-opened. The scripts still rely on shell syntax that does not work on Windows.

Is there any chance it will be fixed?

related to #754

@rolends1986 Could you not be able to find a nastier file sharing hosting? spyware and porn surrounds me...

should be open

commented

i had worked around this problem by importing yoga-layout in Bash on ubuntu on Windows

Prerequisites
Your PC must be running a 64-bit version of Windows 10

Step 1: Activate Ubuntu shell on windows
Step 2: Access ubuntu-bash files from windows
Step 3: (only if you run into nbind errors) npm install nbind

npm i -g npm