AppCenter Yarn 1.19 error Incorrect integrity when fetching from the cache - react-native

I have a React Native app hosted on Microsoft App center. The builds (both iOS and android) are failing because of yarn 1.19 (error Incorrect integrity when fetching from the cache)
I tried to remove the package-lock.json but it didn't help.
I would like to downgrade yarn or execute the cache clean command but don't know where to execute it.
I have installed the appcenter cli version 2.2.1 and successfully connected to it.
Where could I execute yarn cache clean for example?
I've read I could also create a script but I have no idea where to place it and how it should look like. Should it be both in the ios and android directory? Or in the root? Thank you

I actually noticed that I had a yarn.lock back from the initial commit, even though we are using npm in the team.
In the build logs, there is this line:
/bin/sh -c if [ -f yarn.lock ]; then { yarn install && yarn list --depth=0; } else npm install; fi
So I deleted the yarn.lock file and now it builds successfully using npm!

Not sure whether you build your React app with Azure Devops pipeline. If yes, you can use Command line task to achieve the things you want to do.
If the agent you used is hosted agent during the build, since each build will use a completely new VM, you need to install the AppCenter cli once per build.
Use follow command to install the AppCenter cli:
sudo npm install -g appcenter-cli
Then logging in it:
appcenter login --token {Token}
Here, you need first generate the token with this doc described: Go and login to https://appcenter.ms/ -> Click Self Avatar -> Choose Account Settings -> Click on API Tokens -> Click New API token then select the corresponding the scope for this token.
Copy and use it in this pipeline task. Note: Recommend you store
this token with secret variable for security.
Now, you can execute the clean command: yarn cache clean.
Where to place it and how it should look like?
According to your description, you need place this command line task into the first step, then it could clean the Yarn cache firstly.
Also, because of the image configuration that the hosted agent is using, its installed node.js version is 6.7.0, this does not match the runtime environment for AppCenter cli. You need also run Node.js tool installer task to install node.js v10.0.0.
All of them should look like this:
Should it be both in the ios and android directory?
As I mentioned previously, for Hosted agent, each build will use a completely new VM. So yes, you must execute these two steps firstly in every build.
If what you used is your private agent, since you have installed the AppCenter cli locally, the agent will automatically call the local configuration when running the command line task. At this time, you just need to skip the install command in the command task:

We fixed it by adding a "yarn cache clean" in appcenter-post-clone.sh, you can add this shell script in root of project.
See this docs for details.

Related

npm install when deploy Octopus

I need to create node_modules in the root app when deploy new version using Octopus
How can I create a run script using a new octopus step? I try:
npm install
But I get error when execute the script step
'The remote script failed with exit code 1'
Any ideas?
Your build system should be handling that for you. The node_modules directory should then be included in your application package, but ideally, this should also be bundled to reduce the number of files that your application is dependant on.
If you do need to run this as part of a deployment, then you would need NodeJS and npm installed on the server that is executing the deployment step (either the Octopus server itself or a worker instance if using workers).
For more information check out this blog post

How To Get Started With React Admin On Windows

It is difficult to get started or setup this entire repo in Windows?
Can you please give step by step approach to set this up in Windows or a short video tutorial?
I just ran into this issue. My fix was to:
Delete the react-admin directory if you already have a clone from the repo
Update Node and Yarn
-- After update I am currently running Node v10.13.0 && Yarn v1.12.3
Grab a fresh clone of the repo
Then from the react-admin directory run:
yarn
Once that completes:
yarn build
And finally once that completes:
yarn run-demo
lmk if this works for you :-)
There isn't much. Until we add a Windows section in the README, here's how you can get started:
run yarn to install all dependencies
run yarn run-simple to start the playground app and test your changes
There are more scripts in the root package.json file to run tests, demos, etc.
If you need help with something more specific, please precise it in your question

NPM not available when running installation script

I have an interesting issue, I have a setup or rails project and the deployment/upgrades works absolutely fine when running as a dedicated user (deploy) who is used to setup everything.
I am using codeDeploy to manage the deployments and it uses root user to do the deployment on AWS, but during the deployment it fails on running the same script because it's not able to find npm command
cd client && npm run build:client
sh: 1: npm: not found
rake aborted!
Command failed with status (127): [cd client && npm run build:client...]
If i run it manually to check that i also get nothing
root#ip-172-31-4-141:/home/ubuntu# su deploy -c "which npm"
root#ip-172-31-4-141:/home/ubuntu#
NPM is available via the deploy user but I am struggling to understand why it's not available via the root user
deploy#ip-172-31-4-141:/home/ubuntu$ which npm
/home/deploy/.nvm/versions/node/v7.8.0/bin/npm
Any help to get this resolved would be great.
Thanks,
The issue here was that AWS CodeDeploy when starts deployment loads only a minimum env; to load all the env variables I have exported the env and then in the deploy phase source that file, which resolves my issue

Building Autodesk Forge RCDB on Windows 10 fails with node-gyp errors

While attempting to get the Forge Responsive Connected Database to build. I am unable to build this application on my Windows 10 machine. I am unable to succesffuly run “npm install”. I get the following errors as listed below. I ended up trying to use a pre-configured “canvas” and it still didn’t let the node app run.
https://github.com/Autodesk-Forge/forge-rcdb.nodejs
I have tried these solutions to no success:
https://github.com/npm/npm/issues/14543
https://github.com/nodejs/node-gyp#on-windows
https://github.com/Automattic/node-canvas/wiki/Installation---Windows
https://github.com/substack/dnode/issues/181
https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245
https://www.npmjs.com/package/canvas-prebuilt
> canvas#1.6.10 install D:\DEVELOPMENT\Autodesk\forge-rcdb.nodejs3\node_modules\canvas
> node-gyp rebuild
D:\DEVELOPMENT\Autodesk\forge-rcdb.nodejs3\node_modules\canvas>if not defined npm_config_node_gyp (node "C:\Users\steck\AppData\Roaming\nvm\v7.7.1\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
module.js:472
throw err;
^
Error: Cannot find module 'D:\DEVELOPMENT\Autodesk\forge-rcdb.nodejs3\node_modules\canvas\node C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:425:7)
at startup (bootstrap_node.js:146:9)
at bootstrap_node.js:540:3
Here are the full installation and setup steps I tested on two different 2 different computers with Windows10 installed.
Pre-Installations:
Node.js - used v.6.x and v8.x
Node.js global packages:
npm-windows-upgrade(link):
This tool will move and install npm into Windows' spectial folder %appdata%.
Installation steps:
Open Powershell as Administrator and execute Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force.
Install tool by npm install --global --production npm-windows-upgrade
npm-windows-upgrade
Execute cmd npm-windows-upgrade --npm-version 5.6.0 in the Powershell (note. you can choose any version what you want, e.g. 6.0.1)
windows-build-tools(link):
This tool will install build tools required by the package node-gyp.
The installation will take some time to wait for the build tools to be downloaded and installed. If you might see a message Successfully installed Python 2.7 firstly, but you have to wait for the message Successfully installed Visual Studio Build Tools. shows up.
Open Powershell as Administrator and install tool by npm install --global --production windows-build-tools
node-gyp(link):
This tool is required by the package node-canvas while running npm install.
Open Powershell normally(say current user) and install tool by npm install -g node-gyp
Visual Studio 2017 (link):
This might be optional, I just installed it with VS C++ features in my cases.
Chocolatey (link):
This tool will make your life easier to install dependencies for package node-canvas on Windows.
Open Powershell as Administrator and execute Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')).
After installing Chocolatey, install node-canvas dependencies by choco install -y python2 gtk-runtime microsoft-build-tools libjpeg-turbo (You might see a warning message visuallstudiotool-vs2017 installation failed and you can ignore it. In my cases, it didn't affect the result)
GTK with cairo library (link):
This tool the required dependency for package node-canvas.
Installation steps:
Download precompiled X64 GTK package here.
Unzip all contents into C:\GTK.
Mongochef (link):
This tool will make your life easier to restore dummy database of the forge-rcdb.
MongoDB:
You can follow the instructions here to install MongoDB on your compture , or use MongoDB PaaS mlab instead.
Main Installations:
Download source codes of the forge-rcdb and unzip into somewhere you like. In my cases, I put it into my desktop.
Open Powershell normally(say current user) and change directory into the unzipped folder of the source code. For instance, execute cd Desktop\forge-rcdb-nodejs-master in the Powershell.
Run cmd npm install in the root of the source code folder. (You may see some error message while compiling the package node-canvas, but can see 'copied xxx.c', 'copied xxx.cpp', and so on in the same time, then you can ignore the errors. In my cases, it didn't be a problem to run forge-rcdb.)
Configurations:
Open config\development.config.js with your editor and change values of viewer section into:
viewer: {
viewer3D: 'https://developer.api.autodesk.com/derivativeservice/v2/viewers/viewer3D.js?v=4.0.1',
threeJS: 'https://developer.api.autodesk.com/derivativeservice/v2/viewers/three.js?v=4.0.1',
style: 'https://developer.api.autodesk.com/derivativeservice/v2/viewers/style.css?v=4.0.1'
}
Change the database section in the config\development.config.js with you MongoDB connection settings.
Restore dummy database data in the resources/db/dev or resources/db/prod via Mongochef's Import function.
Open Powershell normally(say current user) and set following environment variables:
$env:NODE_ENV="development"
$env:HOT_RELOADING="true"
$env:FORGE_DEV_CLIENT_ID="YOUR_CLINET_ID"
$env:FORGE_DEV_CLIENT_SECRET="YOUR_CLINET_SECRET"
Run the project
Change current directory of the Powershell into the source code folder of the forge-rcdb and type npm start
open http://localhost:3000 in your favorite browser.
Trouble Shooting
You might be not able to load any models in the browser. If you to test the functionality, please copy resources\models\prod\robot into resources\models\dev\robot. Afterward, navigate to http://localhost:3000/configurator in the web browser and mouse-click on Kinematics project, then you will see the model loaded on your screen.
If you see the response of http://localhost:3000/api/forge/user showing HTTP EORROR CODE 404 from the browser dev console, then you must have to check whether the CallBack URL of your Forge App used to host forge-rcdb in Forge Dev Protal is http://localhost:3000/api/forge/callback/oauth. (note. This config can be changed in config\development.config.js)
Afterward, you or your users must have to log into the website with Autodesk account to obtain 3 legged token from the Forge OAuth service to upload models in the gallery page.
If you get an empty array from the response of http://localhost:3000/api/models/configurator?limit=100&offset=0&search=, it means there is nothing in your MongoDB collection configurator.models. To fix this issue, you can import db content resources\db\dev\configurator.models.json into your MongoDB via Mongochef. (note. Please refer the step 3 of the configuration section)
If you cannot load any listed models from the web pages, it means there is not downloaded viewable bubbles in your resources\models\prod or resources\models\dev as well as your Forge OSS bucket. So, please check the urn value in your database whether you have those models in these positions previously mentioned.
If you found the main reason for item 3 of Trouble Shooting is that you didn't own models listed in the forge-rcdb, that's because these models are Autodesk's private models or uploaded by other users themselves before, that might not be shared to the public, unfortunately. To fix this issue, you have to change the example data of MongoDB Collections mentioned in step 3 of the configuration section to your own models.
Hope it helps.

How to use yarn with private npm registry in Sonatyoe Nexus OSS?

I ve setup the nexus oss 3 and it looks cool. All my projects are installed by using yarn because of the --pure-lockfile option.
Steps to reproduce the issue:
1. Setup nexus oss 3 with a private npm registry (as in documentation)
2. Disable anonymous access from nexus oss 3 admin panel
3. On a linux server with alpine try to yarn install --pure-lockfile (you must have a package that is hosted on the private repo in package.json)
4. Does not work, return 401 error
I tried everything but i could not manage to make yarn to login to get those packages.
If i use npm install, it works.
Can someone tell me how to make yarn work nexus oss3 using the setup from above?
If npm install is working, then you must have login credentials and repository correctly defined.
Open terminal and run npm login, give your username and password for nexus account. This will create a file ~/.npmrc. Open this file nano ~/.npmrc, output look like
//<repository>:_authToken=NpmToken.<token>
A dummy example:
//test.server.com/repository/npm-group/:_authToken=NpmToken.123456-12345-12345-tok-en0onum
Go to the project directory cd <project_dir>, create a new file .yarnrc, open it nano .yarnrc. Insert the following line, save and exit (Ctrl+O, Ctrl+X) it.
registry "<repository>"
Create another file .npmrc in the same directory <project_dir>. Open, add the following line, save and exsit.
registry=<repository>
always-auth=true
//<repository>:_authToken=NpmToken.<token>
Delete the .npmrc at home directory rm ~/.npmrc.
Now you can download node_modules with yarn or yarn install.
I had same issue with nexus 3 and use this configuration on my .npmrc file:
registry=https://your.nexus.com/repository/some-npm/
always-auth=true
/* basic-auth-token: your user:password in base64 */
_auth=<basic-auth-token>
Hope this help you!
The fact that your requests returns 401 (Unauthorized) means that you should supply credentials when connecting to Nexus.
It is far from being a nice solution but I got it working using
yarn set registry https://user:pwd#your.nexus.host/nexus3/repository/npmjs/
I use yarn 1.4.0 (release candidate). It should also work on 1.3.2, but I cannot test that because 1.3.2 has issues with HTTPS_PROXY env vars.