Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update npm modules, ignoring a git repo

Tags:

git

npm

I forked one of npm modules and now it is a git repo.

So my package.json:

"dependencies": {     "some-module": "git+https://github.com/my-name/some-module.git", } 

Forked repo is synchronized by fetching upstream and merging. But when I try to update other npm modules it gives error:

npm ERR! git Appears to be a git repo or submodule. npm ERR! git     /Users/.../node_modules/some-module npm ERR! git Refusing to remove it. Update manually, npm ERR! git or move it out of the way first.  npm ERR! System Darwin 13.4.0 npm ERR! command "node" "/usr/local/bin/npm" "update" npm ERR! cwd /Users/... npm ERR! node -v v0.10.32 npm ERR! npm -v 1.4.28 npm ERR! path /Users/.../node_modules/some-module npm ERR! code EISGIT npm ERR!  npm ERR! Additional logging details can be found in: npm ERR!     /Users/.../npm-debug.log npm ERR! not ok code 0 

Is there any way to ignore git repo when updating? Or to skip this error?

like image 428
IvanZh Avatar asked Dec 08 '14 11:12

IvanZh


People also ask

Should I add node modules to git ignore?

You should not include folder node_modules in your . gitignore file (or rather you should include folder node_modules in your source deployed to Heroku). If folder node_modules: exists then npm install will use those vendored libraries and will rebuild any binary dependencies with npm rebuild .


2 Answers

npm checks all directories for the existance of a .git directory, and throws the EISGIT error if it exists, so there is no way to ignore it or skip it.

The code does however check if it's a link:

mod.parent && !mod.isLink && [checkGit, mod.realpath], 

So I was able to make it work by symlinking the module into node_modules.

$ ln -s ../some-module node_modules 
like image 77
bolav Avatar answered Sep 30 '22 17:09

bolav


I too had this issue whilst doing an npm install library and I was able to solve it by removing the .git directory (which is hidden inside node_modules/library_name) from the corresponding library_name mentioned in the error message.

Also make sure you don't delete the .git directory from the root of your project because if you delete the .git directory from the project root you will lose git related info like branch info,etc

Thanks to bolav for good a explanation regarding how the EISGIT error is thrown.

like image 43
Jose Kj Avatar answered Sep 30 '22 17:09

Jose Kj