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?
Related
trying to setup yarn scoped registry using example here
but the installer keeps appending scope name to the url.
.yarnrc
#myscope:registry" "https://artifactory.mycompany.com/artifactory/api/npm/myco
package.json
"dependencies": {
"#myscope/web-components": "0.0.29",
yarn install --verbose
Performing "GET" request to "https://artifactory.mycompany.com/artifactory/api/npm/myco/#myscope%2fweb-components finished with status code 404.
verbose 1.176178875 Error: Couldn't find package "#myscope/web-components#0.0.29" required by "web#0.1.0" on the "npm" registry.".
so #myscope%2f is injected into the request address.
expcting
https://artifactory.mycompany.com/artifactory/api/npm/myco/web-components
getting
https://artifactory.mycompany.com/artifactory/api/npm/myco/#myscope%2fweb-components
yarn version
1.22.19
I have project that is using npm. Some of the dependencies exist in a registry that can only be accessed over a VPN. Getting on the VPN can be onerous for developers and build machines so we don't want to require people to be on it while running npm install.
In order to solve this, I had created a directory called node_modules_local. I installed the VPN-specific dependencies while connected to the VPN then moved them to the node_modules_local folder. I updated package.json look like this:
"dependencies": {
"core-js": "^2.6.5",
"dep_1": "file:node_modules_local/dep_1",
"dep_2": "file:node_modules_local/dep_2",
...
}
After that, running npm install installed everything without requiring VPN access. It seems to work, but is this a valid approach?
I'm using node 8.7.0 and npm 5.4.2 in this case.
My team and I use Yarn for this because it's easy to set up an offline mirror.
Pull down your packages into some directory (e.g. #angular-core-7.2.0.tgz)
Set up an offline mirror yarn config set yarn-offline-mirror C:\my\local\repo
Run yarn install --offline --freeze-lockfile to download the dependencies from the offline mirror
You may need to run yarn install --offline to generate a yarn.lock file before running with the --freeze-lockfile option.
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.
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
In an asp.net core project all the client files must to be copied under the approot directory to be deployed correctly: jspm let you define a proper directory for client deps, but with npm I have to copy the files from node_modules
directory to the approot\node_modules using a gulp task.
Since I'm not interested in filtering or manipulating the files before the deploy, but I just what that the files in the installed module are deployed, there is some way to do this without use gulp ?
You can use npm to do that. Add a script to your package.json:
"scripts": {
"copy": "xcopy from to"
}
Then you can call npm run-script copy to have it executed. I used xcopy as an example, you can use whatever you like. There is some more documentation about scripts in npm.