Error - React Native CI - Azure DevOps - Gulp - azure

I'm trying to use Azure DevOps for a React Native app. I'm using gulp to generate an Android App which already has the signing-configs ready and I don't have any problem with it.
My error in Azure DevOps is:
And my .yml file has the following tasks:
Install Node 8.16.0
npm install
Using gulp task to generate the APK
My CI fails at the 3rd step. I googled so many kinds of stuff, all say to check the Node version which should be greater than 6 as you see I'm already on 8.
So far I tried the below three steps and nothing worked for me.
Installing #react-native-community/cli as a dev dependency or
globally.
Installing gulp globally or as a dev dependency
Generating package.json without lock file and ignoring optional dependencies.
Any idea on how to resolve this?

I was able to solve my issue for now by upgrading to the latest vmImage.
Changing this
vmImage: 'macOS-latest' #This is macOS Mojave
to
vmImage: 'macOS-10.15' #This is macOS Catalina
solved my problem

Related

Deploying when NPM package is outdated

I want to deploy an Angular 12 app that uses d3-org-chart, which in turn imports d3-flextree. When I start my project using ng build it generates the following error:
./node_modules/d3-flextree/src/flextree.js:247:19-26 - Error: Should not import the named export 'version' (imported as 'version') from default-exporting module (only default export is available soon)
I can see that the error was fixed in the project GitHub repository in this commit, and I made the same change locally and it works fine.
Another developer has raised an issue on the project page to get the NPM package updated.
My issue is that the code was fixed in github, but not updated on NPM. So when I use npm install, or when I deploy my app in a docker container which then runs ng build it pulls down the outdated NPM version and the error occurs, preventing startup.
Obviously, this will be fixed when the maintainer updates the NPM package, but until this happens what is the least ugly solution to enable me to deploy my docker container without the error?

Node-sass build issue with Docker

I am working in Docker to containerize the Angular 5 application. This app uses node-sass 4.7.2. The application works fine in the Windows environment. During "npm install", it downloads the node-sass or builds the same using the sass-library-path defined in .npmrc file.
But, there are a lot of issues during the docker image creation process. It automatically tries to download binding.node file from https://github.com/sass/node-sass/releases/download/v4.7.2/linux-x64-72_binding.node
But, there is no release for linux-x64-72. So, it downloads a dummy file(sized about 4KB) and throws "invalid ELF header" error.
If I specify some valid URL in sass-binary-path(https://github.com/sass/node-sass/releases/download/v4.7.2/linux-x64-59_binding.node), it throws "no module found" error.
I tried with npm rebuild node-sass as well. I saw a lot of answers from the internet as well. Many of the answers suggested me to copy node-modules from the local environment. You know, this is never an option with Docker. I can't ask developers to commit node-modules also in the repository.
Is there any way to resolve this issue? or Is there any simple solution to solve it in the angular application like not using node-sass?
There was a node sass version specified in the package.json. For the corresponding node-sass version, there is no library available for the os linux-x64-72_binding.node.
So, I upgraded the node-sass version in the package.json for which the Linux library was available.
Then, it downloaded the file without any issues.

Node-sass doesn't have binding with node version which uses in TestCafe Docker Image

Initially, i faced the issue, that concurrency doesn't work in Jenkins. I find this issue in official repository and followed advise to update Testcafe Docker Image to latest version (i took it from testcafe/testcafe repository). However, now i faced another issue. We have node-sass package using for web app which i test, and node-sass doesn't work with Node 10.x and displays this error message
Module build failed: Error: Missing binding /tests/node_modules/node-sass/vendor/linux_musl-x64-64/binding.node
Node Sass could not find a binding for your current environment: Linux/musl 64-bit with Node.js 10.x
Found bindings for the following environments:
- Linux/musl 64-bit with Node.js 8.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
Is there is some workaround for it, or maybe Testcafe can use Node 8.x and then you can provide Docker Image with this node version?
At the moment we do not have plans to create multiple testcafe docker images for different node versions. However, I created a separate feature request.
Please track that ticket and vote for it. We can add it to our plans in the future.

VSTS with gulp v.4.0.0

I'm having the gulp version of one of my projects. Previously we were using version 3.9.1 and we were hestitative updating.
After updating i have fixed all local issues and tested the project on a different computer (after updating the installed gulp there as well) it works fine.
Our automatic deployment however won't agree with me.
After a check-in our VSTS does the following steps
install npm
execute command
build project
However, this produces the following error.
Working directory changed to D:\a\1\s\MVC
Using gulpfile D:\a\1\s\MVC\gulpfile.js
C:\NPM\Modules\node_modules\gulp\bin\gulp.js:129
gulpInst.start.apply(gulpInst, toRun);
^
TypeError: Cannot read property 'apply' of undefined
at C:\NPM\Modules\node_modules\gulp\bin\gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
This error seems to be caused by an out of date cli version of gulp. But i can't figure out how to update this using VSTS.
Concrete problem
How do i update gulp cli in VSTS
What have i done already?
After some checking i saw the npm version installed was very old (3.10.8). I've dragged in a nodejs installer which updates to the latest version and gives me the latest version of nodejs, and a much newer version of npm (5.6.0) which i've used at on-hands computers to update the cli version. however i can't figure out how to do this in VSTS.
It seems that you are using Hosted Agent which the installed npm version is 3.10.8. You just need to add a Node Tool Installer task in your build definition and set it to use "8.x" version. It will install the 8.x version which include npm 5.6.0.
npm version before Node Tool Installer task:
npm version after Node Tool Installer task:
Try to install/update gulp-cli through NPM task:
BTW, the package in package.json will be installed on current project/folder instead of global, you need to call gulp command through npm command (scripts property of package.json) to use package in current project/folder or specify the path directly (e.g. ./node_modules/gulp/bin/gulp)
The solution that I found worked for me was to change the Pipeline from Hosted to Hosted VS2017.
I had completed a PR that upgraded the Gulp to 4.0, and the PR build completed but the CI build failed with strange results. After a lot of searching, I narrowed it down to the PR build already being set to Hosted VS2017 (it was building C# projects too that required them) and the CI build was only doing the Gulp build and was set to Hosted.

Build npm package in Windows pre build in Linux

I have a downloaded a project which has been developed and previously build in npm in Linux environment. I want to build and use it in Windows environment. Other than the dependencies shown in the package.json file there were few other dependencies error like bower, grunt etc. which I solved it manually.
I am not able to build and run it.
Can anyone please suggest the steps for building and running the package in Windows environment.
Thanks

Resources