Can you `npm install` from Team Services git repo? - node.js

I can successfully
git clone https://[org].visualstudio.com/_git/[repo]
but if I run
npm install https://[org].visualstudio.com/_git/[repo] --save
I get
npm ERR! fetch failed https://[org].visualstudio.com/_git/[repo]
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 203
Is it possible to install npm packages from Team Services git repos like you can from github?

If you want to install a package from a specific Git repo you need to structure the URL as follows, notice that the url is prepended with git+https://
npm i --save git+https://[org].visualstudio.com/_git/[repo]
This will also work if you want to install your repo over ssh
npm i --save git+ssh://git#github.com:<owner>/<repo>
You can add these style repo URL's to your package.json dependencies as well
"dependencies": {
"custom-pkg": "git+https://[org].visualstudio.com/_git/[repo]"
}
You can read more about the different ways to install directly from git with npm in the npm install docs

If you want to install a specific branch, you can run:
npm install git+https://[org]#dev.azure.com/[org]/Products/_git/[repo]#[branch]

Related

Installing npm package fails with 404

Using the command prompt, I am trying to install angular CLI and it fails. I have npm version 5.5.1 and node version v8.9.1. I am trying to install angular cli using the command
npm install -g #angular/cli#latest
and it fails with the error:
npm ERR! code E404
npm ERR! 404 Not Found: #angular/cli#latest
npm ERR! A complete log of this run can be found in:
I look at the log file and I see its trying to fetch the package from a location that doesn't exist. Not sure from where it gets pulled. How do I fix this location path and install angular cli. Same happens when I try to install typescript or any other npm package. all of them try to install from the location mentioned below and it fails with 404
8 http fetch GET 404
http://nuget.feed.xyz.corp:8729/npm/FeedNPM/#angular%2fcli 109ms
9 silly fetchPackageMetaData error for #angular/cli#latest 404 Not Found:
#angular/cli#latest
10 verbose stack Error: 404 Not Found: #angular/cli#latest
npm config set registry http://registry.npmjs.org
NPM registry documentation
Try first this commands (in windows run as administrator)
npm config set registry http://registry.npmjs.org
npm install -g #angular/cli
if still not working let's update NPM and nodejs by running this commands
npm -g install npm
npm cache clean -f
npm install -g n
then try to run
npm install -g #angular/cli
This should solve this problem
in my case it was .npmrc file in my project dir, which kept overwriting my global registry url. As soon as I deleted it, I could finally use npm install
Add a .npmrc file in the root of the project. .npmrc will look like below -
#xy:registry=https://xyz.jfrog.io/xyz/api/npm/npm-local/
#xy-app:registry=https://xyz.jfrog.io/xyz/api/npm/npm-local/
And Delete all the field eg - email , auth etc.
Find out what is the registry url of your application and put it into the registry.
Then run command - npm install
And it will work.
It was giving the same error for me when I use office network/vpn as they have 'umbrella' DNS security shield. To solve this issue, connect to personal network and type the below commands:
npm config set registry http://registry.npmjs.org
npm install -g #angular/cli
Alternative, another option to avoid 404 npm error
check if your terminal is in the root directory, if not your npm scripts will not execute
because it will not be able to see the package.json
I had same problem with a private package.
Need to:
npm adduser
npm login
I spent hours on this.
I had to follow the below steps to get it to work (mac).
Delete my LOCAL (not project) .npmrc by running:
rm /Users/<NAME>/.npmrc
Then set the registry:
npm config set registry https://registry.npmjs.org/
Then follow the steps for logging in to npm:
npm login
Check what's in your config list by running:
npm config list
It should look like this:
//registry.npmjs.org/:_authToken = (protected)
registry = "https://registry.npmjs.org/"
Hope it works for you too.
change your access level to public. type this in the terminal
npm --access=public
install your angular.
sudo npm install #ngular/cli
In my case, that's a typo error:
change trct-js-sdk to trtc-js-sdk saved my life.
My solution was as follows because I had a dependency on a private package. If you see the dependency in package.json defined in the format #scope/package, then #scope tells you that it's a scoped package that might be private.
Get the private package owner to grant you access to the package
Upgrade npm
Upgrade node
Add registry using HTTPS (not HTTP), e.g. npm config set registry https://registry.npmjs.org
Do "npm login"
Now run the build
Uninstall NPM & nodejs and install the right way NPM (Ubuntu)
sudo with npm is not recommended
To Uninstall
sudo apt-get remove nodejs
sudo apt-get remove npm
or
sudo apt-get purge nodejs
Followed by proper installation
curl -o-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
To confirm open a new terminal run:
$ command -v nvm
Latest LTS release of NodeJS:
$ nvm install --lts
Set default environment
$ nvm alias default lts/*
Worked for me
I got
error 404 'dotnev#*' is not in this registry.
Deleted .npmrc file in 2 folders back over my project root
and then in the project root folder typed:
npm i dotenv
copied from:
https://www.npmjs.com/package/dotenv
Just run sudo npm config set registry http://registry.npmjs.org and then update your npm.
It is an network error , check your network connection and try to install it again.
the only command line "npm -g install npm" solved the issue for me!
the following link can be helpful to dig deep for a better understanding.
Thanks a lot.

npm install trying to install from random fork

I got a node project that work fine at work on mac, but on windows at home it give me a access right error when I try to do npm install.
in my package.json I have this
"dependencies": {
"async": "2.1.4"
}
and it give me this error
npm ERR! Command failed: git -c core.longpaths=true clone C:\Users\username\AppData\Roaming\npm-cache\_git-remotes\git-github-com-jstewmon-async-git-e757f9b4 C:\Users\username\.babun\cygwin\tmp\npm-17984-bd5d3a5c\git-cache-52562eee\c6a89a49b0d525c41545e8afd9a4fe844033cc52
npm ERR! Cloning into 'C:\Users\username\.babun\cygwin\tmp\npm-17984-bd5d3a5c\git-cache-52562eee\c6a89a49b0d525c41545e8afd9a4fe844033cc52'...
npm ERR! fatal: '/cygdrive/c/Users/username/AppData/Roaming/npm-cache/_git-remotes/git-github-com-jstewmon-async-git-e757f9b4/C:\Users\username\AppData\Roaming\npm-cache\_git-remotes\git-github-com-jstewmon-async-git-e757f9b4' does not appear to be a git repository
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
seem to be trying to install from a fork of async.. I don't get it.
git-github-com-jstewmon-async-git-e757f9b4
https://github.com/jstewmon/async
I tried npm clean cache with no success.
As mentioned in npm issue 7456
I can confirm that this command fails "does not appear to be a git repository" when using the current git bundled with Cygwin (2.4.5) 64 bit.
When I separately download and install the Windows git distribution (2.6.2.windows.1) (now 2017 2.12.0), and put the GIT_HOME in front of the CYGWIN_HOME in the PATH, the npm install (including the git clone) succeeds.
I installed with the mintty option so that git works properly with docker also.
If you don't want to install Git on Windows, you can instead follow:
"npm_on_cygwin"
It involved a patched git.js, which will properly managed Windows path, instead of blindly concatenate it as in /cygdrive/c/.../C:\Users\....
The OP Devilwarriors mentions in the comments the npm issue 12821, a similar problem of double Git installed:
babun's sandboxed git can't download git repos when used through npm.
To solve this, you can uninstall babun's git with pact remove git and use the Git for Windows that you already have installed.

Install node module from own gitlab server

I'd like to install node modules from our gitlab server. This is a link to a repository:
http://ABCD-GITLAB/myGroup/myNodeModule.git
According to the npm install guide the install command should be this:
gitlabUser: me
myProject: myNodeModule
npm install gitlab:mygitlabuser/myproject
I have no idea how to reference my
gitlab server url
group
project
account name
I tried some commands but all failed:
npm install gitlab:ABCD-GITLAB:me/myproject
npm install gitlab:ABCD-GITLAB:me/myproject.git
npm install gitlab:http://ABCD-GITLAB:me/myproject
npm install gitlab:http://ABCD-GITLAB:me/myproject.git
npm install gitlab:http://ABCD-GITLAB:me/myGroup/myproject
npm install gitlab:http://ABCD-GITLAB:me/myGroup/myproject.git
npm install gitlab:http://ABCD-GITLAB:me/myGroup/myproject.git
What is the correct way to reference a npm dependency, a clear structure would be great like
npm install gitlab:<serverUrl/>:<username/>/<groupname/>/<projectname/><gitsuffix>.git
I would try one of these:
npm install git+ssh://git#ABCD-GITLAB:myGroup/myNodeModule.git
npm install git+https://git#ABCD-GITLAB/myGroup/myNodeModule.git
npm install git://ABCD-GITLAB/myGroup/myNodeModule.git
You may need to change git to your username and you can add #v1.0.27 or something like that at the end for a specific version or tag:
npm install git://ABCD-GITLAB/myGroup/myNodeModule.git#v1.0.27
You can also install from a tarball:
npm install https://ABCD-GITLAB:myGroup/myNodeModule/repository/archive.tar.gz
You can add ?ref=master to the end of the tarball URL for the branch.

NPM: revert installed packages

I'm working in a Node.js application with npm and git. When I add new npm packages I use npm <package> --save and it is saved on 'package.json' file.
The thing is that when I use git reset --hard, the 'package.json' file is reverted, but the packages are still installed.
The question is: how can I uninstall automatically npm packages that I have installed before the git reset --hard?
After reverting, you can try npm prune option. This will unbuild all the packages not there in package.json
npm prune

Installing bootstrap with npm is failing

I am attempting to install bootstrap (LESS) with npm on Debian but it keeps failing.
This is exactly what i am doing:
git clone https://github.com/twbs/bootstrap.git
npm install
The error i get is simply Killed.
Running the npm install in verbose i do not get any error:
npm verb readDependencies using package.json deps
npm http GET https://registry.npmjs.org/postcss/-/postcss-2.2.5.tgz
npm info retry fetch attempt 1 at 01:00:50
npm verb fetch to= /tmp/npm-3690-Rr0nZSRK/registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000010.tgz
npm info postinstall ansi-regex#0.2.1
Killed
npm install
simply installs the upstream dependencies based on what is listed in the package.json in your current directory
Try this
git clone https://github.com/twbs/bootstrap.git
cd bootstrap
npm install # installs dependencies
npm install -g bootstrap # does actual install of bootstrap into module dir
note the -g in the install command puts bootstrap into your global npm module directory
as defined by environment variable $NODE_PATH
You can also low down memory consumption by "npm config set jobs 1", did work for me ;) link: https://community.c9.io/t/npm-install-is-killed/847

Resources