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.
Related
I forked and module on Github, changed it for my needs and pushed back to git. Now I am trying to install this module with npm with
npm install git+http://github.com/username/modulename.git
But I get the following error:
npm ERR! Command failed: git submodule update -q --init --recursive
npm ERR! fatal: O:/Programs/Git/mingw64/libexec/git-core\git-submodule cannot be used without a working tree.
What can cause it and how to fix it?
Check if this is similar to this thread:
After a bit of debugging, I have determined that this actually works if I use the url "https://github.com/nfroidure/ttf2woff2#master" instead.
This is because it is doing a shallow clone, which doesn’t use --mirror, so isn’t a bare repository.
So in your case:
npm install "https://github.com/username/modulename.git#master"
So I wanted to help out, and forked a Node-RED module to make some small contribution, but then got lost messing around with how to get Node-RED to run my fork (for testing) rather than the packaged version. Then I learned about npm's ability to install from a Github URL, which is nice, but it wouldn't work because I had already installed the module. Then I found I couldn't uninstall it either
npm uninstall original-module
npm ERR! path /home/nodered/.node-red/node_modules/original-module/package.json
npm ERR! code ELOOP
npm ERR! errno -40
npm ERR! syscall open
npm ERR! ELOOP: too many symbolic links encountered, open '/home/nodered/.node-red/node_modules/original-module/package.json'
so in frustration I deleted the module's directory, only to find myself unable to move forwards, or backwards. npm install https://github.com/me/forkedmodule fails with
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/me/forkedmodule.git /root/.npm/_cacache/tmp/git-clone-d31dc53b
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-d31dc53b': Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-22T01_07_18_257Z-debug.log
and trying to install the original with npm install original-module fails with
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules/original-module" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-22T01_09_56_127Z-debug.log
As you've probably guessed, I'm pretty new to Node.js, Node-RED and npm, but I haven't been able to help myself, so have to ask for help! It seems nonsensical to me that npm appears to be looking for a local copy of the package.json file belonging to the package I'm trying to install?
Edit: I should add that the above commands were all run as root.
Ok, found a solution, not sure if it's the best one though!
In the "project" directory (/home/nodered/.nodered in my case) there's a package-lock.json file which lists the packages used by the project. In there I found an entry for the original-module which I removed, after which I was able to install the package "normally" with npm install original-module.
Then to solve the permission issue when installing from a GitHub URL, I found I needed to impersonate the "nodered" user with su - nodered (it's a password-less user in my case). As "nodered" npm install https://github.com/me/forkedmodule succeeded without any error. A little curious since I was trying to do this as root before, and got a permission error, but there you go. I also took the opportunity to chown -R the project's node_modules directory to nodered:nodered as I could see that was a bit of mess.
In future, I will try to remember to su - to my nodered user first, and navigating to the project root (again, /home/nodered/.node-red in my case) before running npm install anything. Hopefully that will avoid any further issues. Oh and a note to anyone else who just wants to contrib some quick changes to a module hosted on GitHub: to "pull" in changes you simply run npm install https://github.com/me/forkedmodule again - npm doesn't appear to provide any dedicated "update" method.
I had the same issue, in my case the solution was to delete the package-lock.json, delete node_modules, then reinstall npm modules.
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]
I'm getting an error deploying to Elastic Beanstalk, because there is no git on the instance. One of the dependencies in my package.json is dependant on a git repository and needs to git clone.
Git is not installed on the instances. I tried installing it through .ebextensions .conf file while deploying, through yum, but when I ssh into the instance it's not there.
Question is: what is the correct way to install and have git on a Linux instance running on Elastic Beanstalk before npm install is called on that instance?
Here's the log showing the error:
[2015-04-18T09:00:02.815Z] ERROR [1777] : Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError)
caused by: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
npm WARN package.json amity-api-v2#2.0.0 No repository field.
npm WARN package.json amity-api-v2#2.0.0 No README data
npm WARN `git config --get remote.origin.url` returned wrong result (https://github.com/awslabs/dynamodb-document-js-sdk) undefined
npm WARN `git config --get remote.origin.url` returned wrong result (https://github.com/awslabs/dynamodb-document-js-sdk) undefined
npm ERR! git clone https://github.com/awslabs/dynamodb-document-js-sdk undefined
npm ERR! git clone https://github.com/awslabs/dynamodb-document-js-sdk undefined
npm ERR! Linux 3.14.35-28.38.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v0.12.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v0.12.0-linux-x64/bin/npm" "--production" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ENOGIT
npm ERR! not found: git
npm ERR!
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.
If you put a config file in your .ebextensions folder like this:
packages:
yum:
git: []
Make sure the git package is in a config file with a higher execution index then one that actually requires git. It is common to have it in a first config file named: 00-packages.config.
I can think of three ways you could ensure git(or any dependency) is installed on the system before npm install is run.
Define a preinstall script in your package.json that installs git if required.
You can add a script(file), using ebextensions in either the pre-appdeploy hooks directory, or the preinit hooks directory. I would suggest the preinit hook, as that's where the hook for installing packages is. Just set the path of your script to /opt/ebextensions/hooks/preinit/99_install_git.sh, or if you want to do in pre-appdeploy, /opt/ebextensions/hooks/appdeploy/pre/99_install_git.sh, and make the file executable by using the mode field.
Using ebextensions to install a package.
For your use case, I think #3 is the best option. Kinda late, but I hope you find it useful
Hi I am trying to install a module globally which i made to a gzipped tarball.I downloaded the source from github and converted to a tar.gz and then i tried to install it using the following command
npm install forever.tar.gz -g
It threw me the following error
npm ERR! addLocal Could not install /home/administrator/forever.tar.gz
npm ERR! Error: ENOENT, open '/root/tmp/npm-18157/1367900009061- 0.2676603845320642/package/package.json'
My requirement is that i should not connect to any external url (ie) https://registry.npmjs.org/forever for any installation.I should be able to install from the tarball from my directory.I am stuck here any help will be much appreciated.
this error tells you, that the package.json in your tar was not found...
did you change something in your repository? how did you tarball the repo?
i did these steps and everything worked fine:
git clone https://github.com/nodejitsu/forever.git
tar -cvzf forever.tar.gz forever
npm install forever.tar.gz -g
hint: you dont need to tarball the repository, npm install can also be performed on local folders:
git clone https://github.com/nodejitsu/forever.git
npm install forever/