Upstream refuses to support Android (https://github.com/sass/node-sass/issues/1944) but maybe it can be patched on our end.
Hi @Rudloff @fornwall, the issue why node-sass doesn't build on android is related to: termux/termux-packages#307 -> the compiler option in node-gyp / common.gypi is still fPIE (https://github.com/nodejs/node/commit/271201fea935cdf85336736e87c06104ce185f61) and that produces a segfault. In order for build on android, node-sass needs to be compiled with fPIC.
I'm currently trying to see if I can follow the instructions here to provide a build for android.
Just hit this issue, if a fix is coming - fantastic!
@andrewcharnley : I cannot promise how fast I can be.
Therefore, the fastest solution is to build node-sass yourself on android. Just follow the instructions I outlined here: http://blog.akehir.com/2017/05/building-node-sass-libsass-python.html
Followed that and it builds now, however upon usage I have the same message:-
android-arm-48/binding.node has text relocations.... segmentation fault
Hi @andrewcharnley :
This indicates the flags have not been set correctly. What's your node --version?
I just followed the process, and currently it is 6.11.0 -> then the common.gypi in that specific directory needs to be edited (ie. nano ~/.node-gyp/6.11.0/include/node/common.gypi ).
If you edited the old 6.10.3 node directory, but did upgrade packages to install 6.11.0, then it won't work.
Furthermore, there are 2 configs in common.gypi: Debug, and Release. You need to edit both (or, at least the Release config, which is further down in the file) to use -fPIC as compiler option.
Once you've done that you can npm rebuild node-sass -f
I didn't look at common.gypi correctly and only edited the debug config. Working fine now. :)
I tried following same tutorial but there is not common.gypi file available anywhere, any ideas??
node is 6.11.3
The file should be generated when you first try 'npm install node-sass'. It's located in your application user's home directory (cd ~/). The '~' will switch you to your app's home directory (in this case, the termux app - the full path would be something like /data/data/com.termux/home/).
Then, in your home directory, the '.node-gyp' directory would be a hidden directory (see the '.' before the name). So, just running 'ls' will not show the directory, you'd need something like 'ls -la'.
In any case, with node 6.11.3, the common.gypi would be under: ~/.node-gyp/6.11.3/include/node/common.gypi
Thanks, I switched to ruby sass compiler temporarily, now I can switch back to node.
Amazing, would love to see it working. Will check out the guide on building it.
on android 7.1.2 cyanogenmod work fine.
u need install puthon2 and 3 + python2-dev and 3.
edit: I got some erros..
But I recommend using the stylus and stylus-loader
stylus does not need as much bullshit to work as sass haha
it is very similar to sass and I recommend it by
ease of use :)
Any updates?
on android 7.1.2 cyanogenmod work fine.
u need install puthon2 and 3 + python2-dev and 3.edit: I got some erros..
But I recommend using the stylus and stylus-loader
stylus does not need as much bullshit to work as sass hahait is very similar to sass and I recommend it by
ease of use :)
Move node sass to stylus not a solution
ive tried following the steps above and in the linked blog, node sass installs succesfully but during build i get this error
"""
ERROR in ./src/sass/app.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/sass/app.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Error: dlopen failed: cannot locate symbol "__atomic_fetch_add_4" referenced by "/data/data/com.termux/files/home/davidBlogs/node_modules/node-sass/vendor/android-arm-79/binding.node"...
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1024:18)
at Module.load (internal/modules/cjs/loader.js:813:32)
at Function.Module._load (internal/modules/cjs/loader.js:725:14)
at Module.require (internal/modules/cjs/loader.js:850:19)
at require (internal/modules/cjs/helpers.js:74:18)
at module.exports (/data/data/com.termux/files/home/davidBlogs/node_modules/node-sass/lib/binding.js:19:10)
at Object.
at Module._compile (internal/modules/cjs/loader.js:958:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:994:10)
at Module.load (internal/modules/cjs/loader.js:813:32)
@ ./src/sass/app.scss 1:14-122 20:4-31:5 23:25-133
@ multi ./src/js/index.js ./src/sass/app.scss
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
[./node_modules/html-webpack-plugin/lib/loader.js!./node_modules/html-webpack-template/index.ejs] 6.74 KiB {0} [built]
[./node_modules/lodash/lodash.js] 528
"""
same thing here.
Most helpful comment
@andrewcharnley : I cannot promise how fast I can be.
Therefore, the fastest solution is to build node-sass yourself on android. Just follow the instructions I outlined here: http://blog.akehir.com/2017/05/building-node-sass-libsass-python.html