Skip to content

[5.0] Add "node_modules" to .gitignore #3240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2015

Conversation

danharper
Copy link
Contributor

Seems sensible if Laravel's going to push Elixir.

A person unfamiliar with the node ecosystem should be able to use Elixir with ease, however I don't feel they should necessarily know up-front that they should add node_modules to their global .gitignore file.

Seems sensible if Laravel's going to push Elixir.

A person unfamiliar with the node ecosystem should be able to use Elixir with ease, however I don't feel they should necessarily know up-front that they should add node_modules to their global .gitignore file.
@danharper
Copy link
Contributor Author

I'm aware this issue has appeared a few times and it's be declined, however I really feel this is just one less hurdle to using Elixir & everything Node.

@appleboy
Copy link

appleboy commented Feb 1, 2015

Please add node_module into your global ignore setting. The Laravel project doesn't contain package.json so why add "node_modules" to .gitignore.

@danharper
Copy link
Contributor Author

Nope, L5 contains a package.json to ease people into Elixir: https://github.com/laravel/laravel/blob/develop/package.json

@jrahmy
Copy link

jrahmy commented Feb 1, 2015

Still, node_modules belongs in your global gitignore. It's not specific to Laravel.

@jahvi
Copy link

jahvi commented Feb 2, 2015

Stuff like node_modules, .DS_Store and the likes don't belong in .gitignore files but the global ignore file.

.gitignore is for project specific files.

@RomainLanz
Copy link

Laravel 5 use NodeJS (https://github.com/laravel/laravel/blob/develop/package.json) so node_modules should go in .gitignore file.

@danharper
Copy link
Contributor Author

Yes, it should be in your global .gitignore, but put yourself in the shoes of someone who hasn't used Node and wants to try this cool new "Elixir" feature in Laravel.

They'd follow the docs, npm install and now they've got this node_modules dir sitting on the git stage.

Then imagine they share their project with someone else on their team. Now everyone else has to learn this best-practice from Node's eco-system.

I'm all for encouraging a best-practice, but I think it's just common sense to make this a default. (Yes, Homestead may come with this built-in, but not everyone will use it).

@danharper danharper changed the title Add "node_modules" to .gitignore [5.0] Add "node_modules" to .gitignore Feb 2, 2015
@martindilling
Copy link

Can't see why /node_modules shouldn't be in gitignore, when /vendor is? I think it makes sense, and it would definitely help many more people than it would hurt :)

@barryvdh
Copy link
Contributor

barryvdh commented Feb 3, 2015

I also think /node_modules should just be in there.

@jahvi
Copy link

jahvi commented Feb 3, 2015

The problem with adding node_modules here is encouraging bad practices, what about adding .DS_Store? A lot of people use OSX to develop so it should be added as well right? Maybe add .swp files since a lot of people use Vim or *.project files for all the people that use Sublime Text?

Adding node_modules will open the door to cater for all these files when it shouldn't because they have nothing to do with this project, they should be added in a global ignore file. There's no need to make the .gitignore file unnecessary long. The vendor folder is added because composer is a hard dependency, Laravel needs this to work so it's considered part of the project, whereas gulp is optional.

I think it'd be better to add a reference to this in the documentation to encourage people to set up a global ignore file instead.

@barryvdh
Copy link
Contributor

barryvdh commented Feb 3, 2015

Imho node_modules is different the IDE/OS specific files. It's a file that's always generated when using npm install with the default package.json file.
It might not always be used, but the package.json and gulpfile are also in the project repo. Elixir comes default with every L5 install, so don't see why you wouldn't update the gitignore file.

Also, I'm not sure if the node _modules folder even belongs in a global gitignore. It might for php development but when you're creating node apps you might want to include the dependencies..

@RomainLanz
Copy link

@jahvi I agree with you about IDE/OS files. But Laravel 5 use NodeJS so it's a project specific folder.

With your reflexion we can also pull out /vendor.

@jahvi
Copy link

jahvi commented Feb 3, 2015

@RomainLanz Yes but L5 doesn't rely on NodeJS, you can take it out and it'll still work however if you take the vendor folder out it won't work.

I agree with @barryvdh in a way though, it could be added just because elixir comes by default to avoid confusion. I think global ignore is just for OS/Editor specific files, I may have added it because I never work on Node apps.

@RomainLanz
Copy link

Yes, Laravel 5 doesn't rely on NodeJS but the default installation has Elixir that rely on NodeJS. When you do a fresh install of Laravel 5 and want to commit on your repository the node_modules folder will be committed too.

@rtablada
Copy link

rtablada commented Feb 3, 2015

I agree that at this point with the addition of elixir that node_modules should be ignored by git. Node offers a shrink wrap similar to composer.lock to lock files so that's no longer an issue as before.

Node modules aren't the same as ide or is folders/files at all. Instead it is much more comparable to the vendor dir that composer creates.

In the past I was on the fence as this would possibly open the floodgates for people to ask for other dep folders from other dev tools, however the blessing of elixir and a package.json file in L5 lock me into saying that node modules should be included. The same argument could not be made for other folders for other package managers (ie bower)

@rtablada
Copy link

rtablada commented Feb 3, 2015

Also with older versions of npm not supporting shrinkwrap, there are legacy projects that unfortunately do need committed node_modules directories.

@chriscook
Copy link

I agree with @barryvdh - I was under the impression that your global ignore file is for things specific to you (i.e. folders created by your IDE or OS), whereas the local/version-controlled ignore file should include things specific to the project.

@jrahmy
Copy link

jrahmy commented Feb 3, 2015

Actually, with Elixir becoming a default part of Laravel I do agree that it should be in the .gitignore file.

Still, if you use node on more than on project (also goes for composer), adding it globally is a good idea. I think for those just getting started with Laravel adding it to the local .gitignore would be a welcome change.

taylorotwell added a commit that referenced this pull request Feb 4, 2015
[5.0] Add "node_modules" to .gitignore
@taylorotwell taylorotwell merged commit b07b9f8 into laravel:develop Feb 4, 2015
@danharper danharper deleted the patch-1 branch February 4, 2015 14:19
@yasinkocak
Copy link

This should be in global .gitignore
Check here how u create one
http://competa.com/blog/2014/12/creating-a-global-gitignore/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.