Is it possible to override yarn install to use https instead of git - npm-install

I have following dependency in package.json
"devDependencies": {
"vue-particles": "github:creotip/vue-particles"
}
yarn install is failing as I do not have ssh keys setup where I was running the command.
Is it possible for me to force it use https instead of git/ssh

One solution is to override url using fillowing command
git config --global url."https://github".insteadOf ssh://git#github

Related

How to use Yarn 2 (or 3) to run create-react-app without specifying a new directory?

I am trying to migrate from NPM to Yarn for the sole reason of getting rid of 'node_modules' folder.
I am trying to use CRA tool. However, on CRA it advises to use yarn create, which is not a command found in Yarn 2 documentation. After some research I found out that I should use yarn dlx command, which is equivalent to npx.
The problem is that to use yarn dlx, I must have Yarn 2 first. Yarn 2 requires that I install it locally in my project directory. This way, I am forced to have a second layer of folder structure.
I want to create-react-app in a folder on my Desktop called myApp. But, I need to create myApp folder to install Yarn 2 before I can even start using dlx to run create-react-app.
Am I missing something?
Thank you.
I faced the same situation recently... my solution was:
yarn create react-app myApp (yes, is yarn 1.22 in my case)
rename the package.json for a while
yarn init -2 # this will create another package.json
merge the old package.json with the newly created one
yarn install
now you can configure PnP as is described on the Yarn documentation or...
you can create directly whit npx:
npx create-react-app your-app-name --use-pnp
Yes, for now, you have to use the second layer of the folder structure.
Assuming you have the latest version of Node 14.x, 16.x or any higher versions, the minimal instructions are the following.
Prerequisites:
Ensure that corepack is enabled via corepack enable command. This needs to be done only once.
Steps:
mkdir enclosing; cd enclosing - to create enclosing directory
yarn set version stable - to use latest stable Yarn version in the eclosing directory and all of its subdirectories
rm package.json - delete package.json in the enclosing directory, generated by the previous command to not confuse Yarn that the enclosing directory is the root of the project.
yarn create react-app my-app - the project will be generated with Yarn 3 and by default will use PnP install scheme
cd my-app; yarn set version latest - to attach Yarn 3+ to my-app project
Optional step, if you want to use node_modules install scheme with Yarn 3+, inside my-app run yarn config set nodeLinker node-modules
After that, you can move out my-app anywhere and delete enclosing directory.
In order to simplify all this into yarn dlx create-react-app I have opened pull request to create-react-app, please place a thumb up emojo for it here:
https://github.com/facebook/create-react-app/pull/12366

Use custom registy, ideally from package.json

In my package.json I have
"config": {
"registry": "https://registry.example.net"
}
In order to use a local registry. If I execute yarn install --verbose though, I see yarn does not use this but uses its own registry:
Performing "GET" request to "https://registry.yarnpkg.com/ts-node/-/ts-node-8.3.0.tgz".
I managed to set the yarn registry manually
yarn config set registry https://registry.example.net
Even then, in verbose mode, it shows me that it is sending GET requests to registry.yarnpkg.com.
Also I need this to be configured so it also uses this registry on other dev machines and jenkins.
How can I get yarn to use my custom registry, ideally from a config file?

NPM: how to specify registry to publish in the command line?

I'm testing a new version of our npm packages registry. I'd like to run a job in our CI server specifying a registry different of the default.
I tried to execute npm publish --registry "http://nexus.dsv.myhost/nexus/repository/npmjs-registry but it didn't work. It was published to the default registry.
How do I specify a different registry while running npm publish. It is a scoped package.
There's multiple ways to accomplish this.
use npm config to set the registry globally:
npm config set registry http://nexus.dsv.myhost/nexus/repository/npmjs
use npm config to set the registry for the package scope:
npm config set #<your scope here>:registry http://nexus.dsv.myhost/nexus/repository/npmjs
configure your package.json with a publish config:
{
...
"publishConfig": {
"registry": "http://nexus.dsv.myhost/nexus/repository/npmjs"
},
...
}
use npmrc to configure the registry
registry=http://nexus.dsv.myhost/nexus/repository/npmjs
It sounds like you have a scope-specific registry configured somewhere in your npm config.
npm will merge your global, local and CLI-provided config. But any scope-specific config will take precedence over unscoped config regardless of where each of them are defined.
For example, if you have #myscope:registry=xyz in your ~/.npmrc file, that will take precedence over --registry=abc provided on the CLI, because a scope-specific registry always overrides the unscoped registry.
However, you can also pass a scope-specific registry on the CLI itself like this:
npm publish --#myscope:registry=http://nexus.dsv.myhost/nexus/repository/npmjs-registry
Note that because of how nopt (which is what npm uses under the hood to parse the CLI options) parses freeform switches, the = sign here is required. If you use a space instead, it won't work as expected.

NPM fallback dependency URL

I have a npm dependency in my project which is pointing to a private git repo. Unfortunately the git repo link does not work in my local but it works fine when we do a jenkins build since that git repo link only allows certain whitelisted ip's (i.e. jenkins ip address).
I have looked into apache proxypass and verdaccio but I am not sure if that is the right approach for this
dependencies": {
"api-module": "git+https://example/repo-name.git",
},
Locally, I want https://example/repo-name.git to route to https://differentUrl/repo-name.git when I do npm install but don't want to update package.json
I had to setup a host entry and provide an alias to that

Force yarn to ignore npm config

I don't want yarn to use my npm config. Specifically, I want it to ignore my npm registry because I use a custom one for work, which fails if I'm not on the VPN.
I know I can swap the registry out in about 5 seconds, but I imagine it's possible to separate yarn/npm configs.
Yarn comes with the default yarn registry (https://registry.yarnpkg.com). The problem you can't install via yarn is probably because of your SSL? try yarn config set strict-ssl false and see if that works