EAS pre build fails with Azure NPM repository

Trying to build a local preview android apk file. Has been working with EAS Build before but suddenly doesn’t (i’ve been at a 3 weeks break)

From 'eas.json`:

"preview": {
      "android": {
        "buildType": "apk",
        "env": {
          "APP_ENV": "preview"
        }
      },
      "releaseChannel": "preview"
    }
  • Whether you are bare or managed workflow
    Managed
  • Your eas-cli version
    eas-cli@0.44.1
  • What you have tried so far

Updated my local .npmrc file:

//pkgs.dev.azure.com/ntidevel/MDOCFM/_packaging/FM.Mobile.Common/npm/registry/:username=VssSessionToken
//pkgs.dev.azure.com/ntidevel/MDOCFM/_packaging/FM.Mobile.Common/npm/registry/:_password=personal_access_token
//pkgs.dev.azure.com/ntidevel/MDOCFM/_packaging/FM.Mobile.Common/npm/registry/:email=not-used@example.com

registry=https://pkgs.dev.azure.com/ntidevel/MDOCFM/_packaging/FM.Mobile.Common/npm/registry  
always-auth=true

I run this
eas build --platform android --profile=preview

upload to eas and install dependencies is successfull but prebuild step fails with:

Unexpected response: Unauthorized. From url: https://pkgs.dev.azure.com/ntidevel/MDOCFM/_packaging/FM.Mobile.Common/npm/registry/expo-template-bare-minimum/-/expo-template-bare-minimum-43.0.13.tgz

I have also tried to replace the personal_access_token with an invalid value, and then eas build fails locally with:

npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR!     npm login
...

Anyone has an idea what do to?

Still not solved. Tried to remove the always-auth=true. Then it uploads to EAS succesfully but fails in install dependencies:

[stderr] `error An unexpected error occurred: "https://pkgs.dev.azure.com/ntidevel/MDOCFM/_packaging/FM.Mobile.Common/npm/registry/expo/-/expo-43.0.0.tgz: Request failed \"401 Unauthorized\"".`

It seems that the .npmrc file i had in my post is correct and something is off with the prebuild step

We are having the same problems with our verdaccio proxy that requires authentication.

.npmrc is set up as described in the docs

registry=https://npm.ambassify.eu
//npm.ambassify.eu/:_authToken=${NPM_TOKEN}

NPM token is configured in the secrets and detected in the “Prepare project” step:

Build starts fine on EAS, installing dependencies step works fine. Prebuild step fails with this output:

Prebuilding managed project
- Clearing android
✔ Cleared android code
- Creating native project directories (./ios and ./android) and updating .gitignore
[stderr] [11:25:29] Unexpected response: Unauthorized. From url: https://npm.ambassify.eu/expo-template-bare-minimum/-/expo-template-bare-minimum-41.0.15.tgz
- Creating native project directories (./ios and ./android) and updating .gitignore
✖ Failed to create the native project.
[11:25:29] You may want to delete the `./ios` and/or `./android` directories before trying again.
node exited with non-zero code: 1

@ gertsallaerts I created an issue:

Still ongoing, maybe you can add to it?

Otherwise another solution is to use scopes instead:
.npmrc

@ambassify:registry=https://npm.ambassify.eu
//npm.ambassify.eu/:_authToken=${NPM_TOKEN}

prefix in package.json in your private project

"name": "@ambassify/name-of-package-to-share",
"version":  1.0.0
...

in your expo projects package.json:

"dependencies": {
    "@ambassify/name-of-package-to-share": "1.0.0",
...
}

@gertsallaerts did you found a solution?

@rcknti I haven’t had time to debug it all so I added the workaround you suggested where we only fetch our own scoped packages from our registry and leave the rest to NPM. That works for now but isn’t ideal.

Great it the workaround works.

If you get time for debugging you could try

  • set a trailing slash behind registry=https://npm.ambassify.euregistry=https://npm.ambassify.eu/
  • remove package-lock.json/yarn.lock file and reinstall

One more thing, has it been working for you and then suddenly doesn’t work anymore?