I recently forked an npm package and updated it for my needs. Then, I changed the dependency on packages.json to point to my GitHub repo, and it worked fine. But, when npm installed the module, it brought also the git folder (.git). Because of that, when I try to install anything else, npm gives me this error:
npm ERR! path /node_modules/react-native-static-server
npm ERR! code EISGIT
npm ERR! git /node_modules/react-native-static-server: Appears to be a git repo or submodule.
npm ERR! git /node_modules/react-native-static-server
npm ERR! git Refusing to remove it. Update manually,
npm ERR! git or move it out of the way first.
What am I doing wrong? How do I avoid the .git folder from being downloaded?
You can check the repo here: https://github.com/dccarmo/react-native-static-server
EDIT
The dependency in my packages.json:
"react-native-static-server": "dccarmo/react-native-static-server"
This seems to be an old question, but I was running into the same thing today.
I am rather new to git and npm, but I did find something that may be of help to someone.
If the git repo does not have a .gitignore, the .git folder is not downloaded / created.
If the git repo does have a .gitignore, the .git folder is downloaded / created.
I had two repos, one without a .gitignore (because when I made it I was not aware of what .gitignore was or did), and one with a .gitignore. I included both as npm packages in a project, and noticed that the one without the .gitignore was not giving me the EISGIT error (because of the .git folder).
So, after I found this question, I removed the .gitignore from that repo and now it too does not create a .git folder.
Later on, I discovered that adding both a .gitignore and a .npmignore to the project now stops the .git folder from appearing. I did not add .git in my .npmignore.
Related
I am not asking about deploying Node.js app or how do I deal with node_modules package, I am talking about "upload" my own nodejs code to production server.
So far I have tried 3 ways, each with its own pros & cons
git clone. To reduce to the cloned stuff I use git clone --depth 1 -b release_branch. But still I got the files I do not need for deployment, e.g except for .git I also get documents (b/c I put documents in my git repo).
npm install. use npm install git+https://gitusername:gitpassword#myserver/path/to/repo.git. With proper package.json files setting I can get my source codes only, which is what I want. But the problem is the directory structure. After running npm install, the directory is like this,
.
├── node_modules
└── package-lock.json
My package is located inside node_modules alongside with its own dependencies.
npm pack. Then upload (scp in my case) the tgz file to server, then npm install tgz_file.tgz --production But it has the same problem with npm install git+https. It is probably better than npm install git+https b/c I can control my releases.
So is there other ways (simple) that I can get proper directory structure and source codes only ?
BTW, I know this nodejs express app deploying to production but their discussion is not the same as mine.
----- update -----
Now I am kinda sure npm install tarball has some bug, so I just tar xf & npm i I believe this is the simplest solution.
I use symlinks in the node_modules directory for local development.
And I use package-lock.json when pushing to Heroku/Dokku.
When updating the dependencies, I want to update package-lock.json without removing my symlinks and running npm install.
Is there a recommended way to achieve this?
Otherwise, I'll just write a script that does git checkout and runs npm install on a temporary branch, before pushing.
I was trying to install this npm package from its github repo using this command:
npm install --save github:kpdecker/jsdiff
It looked like it went okay, because the diff folder got created inside node_modules but it didn't contain the lib or dist folders and none of its dependencies got installed. These were the only files that get copied:
runtime.js
release-notes.md
package.json
README.md
LICENSE
CONTRIBUTING.md
However, the command above works perfectly when installing other packages. For example:
npm install --save github:visionmedia/express
So, what am I missing. Is there some other command that I'm supposed to run to complete the installation of jsdiff?
This package needs a build step (see the gruntfile.js). So the artifacts (the files that will be generated at the build step wont be checked in the versioning system - git - you wont have to deal with them in your diffs and merge).
Also check out the .npmignore file.
I am a beginner with git and node. So I created a new repository in git, and installed react and babel, and git is telling me that the repository is too large. Literally all I did was run something like this:
created index.html
created app.js
> npm init (initialized package.json)
> npm install --save react react-dom
> npm install --save-dev babel_preset_react
> npm install --save-dev babel_preset_es2015
added babel config to package.json
Maybe I'm missing something, but I haven't even built anything yet, and I'm already getting complaints that my repo is too large. Git desktop is even throwing OutOfMemory exceptions! So I wondered, maybe I'm not supposed to check in the node_modules folder. Then I read this:
https://web.archive.org/posts/nodemodules-in-git.html
But I am even more confused now. The article says you should check in node_modules for projects that you deploy. But doesn't that mean it's still going to be a "large repository?"
At the bottom, the article says not to add node_modules to gitignore. I think gitignore just ignores the files in that folder from being committed to git. So is this telling us to not ignore node_modules? As in, check-in node_modules?
And what is that $ npm rebuild on deploy?
As a beginning to npm and git, can someone explain what I should do in simpler terms?
I just checked the link you shared is broken. We never check-in node_modules to repositories they easily add LOT of MBs to the overall size. Please add the node_modules in .gitignore. You should only checkin package.json to your repository. This is how my .gitignore in AngularJs project looks like,
.idea
node_modules
dist
npm-debug.log*
.DS_Store
If you are worried about the breaking changes due to version upgrade please specify the "~" sign in front of the version no. of packages (package.json) so only the patches will be considered.
Ex.,
"angular": "~1.5.6"
you don`t need to push node_modules into your repo . Add node_modules to gitignore and when you deploy your code on the server you have to install node_modules over there using command :
npm install
As your package.json is updated when you locally install node_modules and it is pushed to repo . When you run npm install on the server , all your packages will be installed which are mentioned in package.json
We're trying to run the command
brunch new MySkeleton MyProject
this results in the error
02 Jul 14:56:30 - error: Error: 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.
We don't use git, and would prefer to avoid switching source control systems right now. Is it possible to use brunch without git?
MySkeleton is stored in a subdirectory of the current directory. Likewise, the idea is to create MyProject in a subdirectory. The same error occurs with full paths, e.g. /JSapps/MySkeleton
The skeleton we're using contains references to other brunch pieces which live in github. So it seems that while brunch itself doesn't intrinsically require git, the fact that the brunch ecosystem is hosted in github makes the installation of a git a de-facto requirement.
But, just because brunch uses git, that doesn't mean we're forced to use it for source control. (Though it does mean we end up with a bunch of .git* files in our source control, which does seems rather "untidy")
brunch new MyProject MySkeleton