fontawesome pro in azure devops - azure

Has anyone been able to get CI builds working with fontawesome pro? Locally my build and fontawesome pro works because I've run these commands
npm config set "#fortawesome:registry" https://npm.fontawesome.com/ && \
npm config set "//npm.fontawesome.com/:_authToken"
However my CI build fails with the message
npm ERR! 404 Not Found: #fortawesome/fontawesome-pro#5.7.1
I've tried setting a .npmrc file but it didn't help. I also tried adding fontawesome's repo in service connections.

You should set the npm config to project level, by adding a .npmrc in the same folder as package.json
The contents of the .npmrc should be
#fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken={your token}

Related

Installing a private package from Gitlab with Yarn

I have a private npm package that is published to the Gitlab Package Registry using a Gitlab CI pipeline.
I want to install this package in a project using yarn.
Following the documentation helped me come up with the following .npmrc file :
//gitlab.com/api/v4/packages/npm/:_authToken=glpat-***********
#my-org:registry=https://gitlab.com/api/v4/packages/npm/
With the above, npm install #my-org/my-package works perfectly.
However, yarn add #my-org/my-package fails. using --verbose shows a 404 :
verbose 1.169823875 Error: https://gitlab.com/api/v4/projects/<my-project-id>/packages/npm/#my-org/my-package/-/#my-org/my-package-1.0.3.tgz: Request failed "404 Not Found"
error An unexpected error occurred: "https://gitlab.com/api/v4/projects/<my-project-id>/packages/npm/#my-org/my-package/-/#my-org/my-package-1.0.3.tgz: Request failed \"404 Not Found\""
The package does exist at version 1.0.3, NPM installs it.
I need to get this to work with Yarn. How can I do this ?
Additionaly, is there a way to take the authToken out of the .npmrc file ?
I also was not able to install it with yarn, but npm was ok.
This this worked out:
npm config set -- //gitlab.com/api/v4/packages/npm/:_authToken=XXX
npm config set -- //gitlab.com/api/v4/projects/<projectID>/packages/npm/:_authToken=XXX
npm config set #my-scope:registry https://gitlab.com/api/v4/packages/npm/
yarn config set '//gitlab.com/api/v4/projects/:_authToken' "XXX"
yarn config set '//gitlab.com/api/v4/packages/npm/:_authToken' "XXX"
And no need for .npmrc for this setup.
Here is the official GitLab docs on that issue.
Your config in .npmrc should work if you are using Yarn v1.x, as Yarn 1 uses the registries configured in this file.
However, for Yarn 2, you must configure your private registries in the .yarnc.yml at the project level:
npmScopes:
my-org:
npmRegistryServer: "https://gitlab.com/api/v4/projects/my-project-id/packages/npm/"
npmAlwaysAuth: true
npmAuthToken: glpat-*******
Replace my-org with the scope of your package, my-project-id with the numeric id of your Gitlab project, and put your token with scope "api".

NPM default registry config to a private repo doesn't work

On my local MacOs, I have set registry npm config to https://<myrepo>.pkgs.visualstudio.com/_packaging/<myrepo>/npm/registry/ in both the project directory .npmrc beside package.json and also in $HOME\.nmprc.
But still, when I run npm i it doesn't replace https://registry.npmjs.org with the one configured above.
What else I am missing to config?
EDIT:
I realized that the problem is with dependency packages.
When I put .npmrc file in the same directory as package.json, running npm install will use the registry in npmrc.
You need to check if the package-lock.json file was generated during your previous npm install.
If yes, you could remove this file and run the npm install again.
Here is a doc about Package-lock.json. And the doc about configure the .npmrc on Mac/linux machine
On the other hand, you can also try to use the following command to set the registry:
npm config set registry feedurl

Install multiple npm packages from private gitlab registry

I'm using gitlab to host my private npm packages. At the moment I've 2 projects I published to the gitlab package registry. Both packages are used by another project (let's say 3rd project). According to the gitlab documentation, I installed both packages in the 3rd project using the following commands:
npm config set #myscope:registry https://gitlab.com/api/v4/projects/<first-project-id>/packages/npm/
npm config set "//gitlab.com/api/v4/projects/<first-project-id>/packages/npm/:_authToken" "<auth-token>"
npm install #myscope/first-package
npm config set #myscope:registry https://gitlab.com/api/v4/projects/<second-project-id>/packages/npm/
npm config set "//gitlab.com/api/v4/projects/<second-project-id>/packages/npm/:_authToken" "<auth-token>"
npm install #myscope/second-package
My problem is now that I cannot run a simple "npm install" anymore because my 3rd project depends on the 2 private packages. Sure, I can call "npm config set" before running "npm install" in the 3rd project, but the problem is that when I call "npm config set" for the second project, it replaces the first config (because both are having the same scope). So I can only install 1 package, for the second I'm getting an error because it cannot be found (because it has another project-id in gitlab, thus another package registry url). I already tried the following without success:
npm config set #myscope/first-package:registry https://gitlab.com/api/v4/projects/<first-project-id>/packages/npm/
npm config set "//gitlab.com/api/v4/projects/<first-project-id>/packages/npm/:_authToken" "<auth-token>"
npm install #myscope/first-package
npm config set #myscope/second-package:registry https://gitlab.com/api/v4/projects/<second-project-id>/packages/npm/
npm config set "//gitlab.com/api/v4/projects/<second-project-id>/packages/npm/:_authToken" "<auth-token>"
npm install #myscope/second-package
But now I cannot install any of the packages. So, anyone know how I can set the registry-url for packages sharing the same scope but having a different url?
I finally solved the issue by using the instance-level installation. First, I thought it's not working for me because it still told me 404. But the problem was that gitlab instructs me to run npm config set '//gitlab.com/api/v4/packages/npm/:_authToken' "<my-token>". But this is not working on my Windows because of the apostrophes that surrounds the url. I replaced them with " and now everything works fine.

npm error E401: Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

I upgraded node version to 12.16.2 and npm version to 6.14.4. After that I am not able to run npm install, as I'm getting this error
code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
I even tried deleting node_modules and package-lock.json and running npm install again, but doesn't change anything.
I had similar issue. I resolved it by adding _auth into my ~/.npmrc. See the doc how to encode your nexus credential. I added the encoded credential using npm config set _auth xxx.
You wont be able to see the value using npm config list or npm config get _auth.
In my case, the problem was I've entered another registry address in same Nexus for npm login command.
npm login --registry=http://nexus_url:port/repository/wrong_address
My problem was solved by logging into correct address:
npm login --registry=http://nexus_url:port/repository/correct_address
what worked for me is :
I deleted the .npmrc file under C/users/ folder.
and ran npx vsts-npm-auth -config .npmrc command to create a new file in the users folder
Deleted the .npmrc file under C/users/ folder
npm set registry=http....
npm set _auth=(login:pass in base64):
I found a way out. With this new npm version they are enforcing authentication to access certain packages. We realised we don't need to use authentication for any of the packages we were downloading, hence the auth code we had was unnecessary. So we just removed it and it all worked.
vsts-npm-auth -config .npmrc -F
Is the only solution I found;
Edit: make sure to run npm install -g vsts-npm-auth before
You can remove package-lock.json .. it works with me
I'm run set's command from the post and add in nexus "Active realms" profile "npm Bearer Token Realm". Links: https://help.sonatype.com/repomanager3/system-configuration/access-control/realms
My problem was solved.
I encountered this error when running an npm install that was pulling some dependencies from a non-public registry located on a self-hosted Azure DevOps (AzDo) server.
I had a .npmrc file in the project, and a .npmrc file in my user profile dir with an AzDo personal access token (PAT) that had allowed access previously. The AzDo UI reported my token as still being valid.
PS C:\src\app> npm install
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="{INTERNAL_REGISTRY_URL}", Negotiate, NTLM
In my case, the solution was to regenerate the AzDo PAT and update the .npmrc found in my user profile directory.
What worked for me was running npm login, then entering my Username, Password, and Email to log in to the registry defined in .npmrc. I then proceeded with npm installing the packages I needed and it worked.
Had the same issue while doing npm i for a private npm registry. Solved it by removing the _authToken parameter from some lines in my .npmrc file in my user's root directory:
Before:
//registry.npm.example.com/:_authToken=NpmToken.XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX
//npm.artifacts.example.io/:_authToken=NpmToken.XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX
update-notifier=false
registry=https://npm.artifacts.example.io/
After:
//registry.npm.example.com/
//npm.artifacts.example.io/
update-notifier=false
registry=https://npm.artifacts.example.io/
In my case the Nexus Authentication and project I am using requires Node version: 12.8.1.
I was using node version: 16.13.2
I use NVM to install 12.8.1 with nvm install 12.8.1
Then nvm use 12.8.1
This will now work on my machine and environment.
if the .npmrc file config like this
//registry.npm.example.com/:_auth="base64(username:psw)"
try this
//registry.npm.example.com/:_authToken="base64(username:psw)"
In my case, npmjs expected a Base64 encoded Personal Access Token in the .npmrc file, and I had forgotten to Base64 encode it before pasting it into the user .npmrc file.
You can try downgrading the current node version, 16, to 14.20.0.
My steps to fix this issue.
Earlier I had configured NODE_HOME under "Environment variable".
I removed it.
Only configured the path.
Created a new folder in the "C" drive and pasted the node files.
(System variable)Path = "C:\Node\node-v14.20.0-win-x64"
I had same issue as I had configured my auth through the .npmrc file by adding the below details to it:
_auth=xxx
always-auth=true
email=example#mail.com
The error was:
npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
then got resolved after removing underscore (_) from auth in the .npmrc file:
auth=xxx
always-auth=true
email=example#mail.com

Which script am I missing when trying to install framework7 custom build?

npm ERR! missing script: build-core:prod
I'm receiving the above error when trying to run the custom build for framework7 - https://framework7.io/docs/custom-build.html
I have gone through each step however I am running into this problem in cmder and I'm unsure why.
The error occurs at step 7 if this info is of any value
Any help would be appreicated.
The error says it cannot find the script build-core:prod.
I could replicate this error (missing build-core:prod), by NOT INSTALLING THE DEPENDENCIES after cloning from github.
So the steps are:
1. Clone the Framework7 Github repository
git clone https://github.com/framework7io/framework7 my-app
this will download the repository in a folder called my-app
2. Install Node.js
that's another topic, hope you have that installed
3. Install Gulp
npm install --global gulp
if you don't have that
4. Install dependencies
cd my-app
npm install
be sure that you are in the root of my-app (the directory you just created for the cloned repository)
this installs all the dependencies that Framework7 Custom Build needs
5. Duplicate my-app/scripts/build-config.js
and rename the duplicate to my-app/scripts/my-config.js
6. Open my-config.js and edit it as you need
7. Go to my-app folder (the root)
and run
npm run build-core:prod -- --config scripts/my-config.js --output path/to/output/folder
path/to/output/folder is a path to the folder where you want the customised files to be, it can be (for example) f7-my-custom-build
8. The custom build is ready,
hopefully you can work with it now. :)

Resources