How can i reduce the size of node_modules folder? - laravel

I've done the application creation using laravel, every time I want to create a front end template using laravel mix, or tailwind, the file should not be too big (less than 100mb). When I run npm install, my development files get really big. I have done many ways that are scattered on the internet, but what is an efficient way to reduce the size of node_modules?

For a laravel web app, you do not need to upload the node_modules to any server to successfully run your app, all you need is to upload the compiled css and js files which are typically located within the public folder. The node_modules folder is only useful when you are in development. And you said you are done with the app which means you are not going to develop soon so you can delete the node_modules folder and your app will be just fine.
And later if you want to add more features, you can just run npm i to install all the packages back which will bring back the node_modules folder.
Hope this helps, if you really want to reduce the size of node_modules due to your disk limitation then all I can say is use fewer packages or choose other packages that have fewer dependencies.

Related

Why do I keep getting node_modules file changes showing up on Git without touching my code?

I've got a pretty simple repository made up of a frontend folder in which I have a react app, and a backend folder that is mostly empty for now.
Every few minutes, regardless of whether or not I make any changes to any files, some node_modules file will pop up in GitHub desktop showing a difference.
screenshot of my github desktop
Do I need to add node_modules to my .gitignore file?
This didn't happen before, I don't know what happened to trigger this. I add the changes because I assume it's an important node_modules update but then it happens again a few minutes later.
I'd like to understand why this is happening and how I can prevent it from happening as it makes my commit history impossible to read.
Simplest solution would be to gitignore node modules like so...
/node_modules
Unless you have a specific reason to track changes to npm?
It's usually better to install fresh packages via npm install when setting up on a different enviroment/device.

Problems for laravel project on share hosting server where I cannot run npm run dev or build

I used jetstream laravel authentication and I used npm run dev and keep it running on my cmd while I developed my project locally. Everything was OK till here. But now I want to upload on a shared hosting. And I got it that I need to run npm run build now. I have run it locally and uploaded the files but my ui of my project has been all scattered and misplaced. So I know I have missed a/some steps. What really have I missed out or have wrongly done.I am stuck now.
Regarding my web hosting ,I have my project files outside the public_html. All the public files are moved in this folder public_html.My database and my application working fine except the ui is messy.
I have find out a way but still do not know whether it is the best solution or proper one.
What actually the scenario is that the build folder of the npm run dev is folder project_folder/public/build but I have my project files outside the public_html folder. So it was unable to find the manifest.json in the folder project_folder/public/build. It was not working ,the UI is very ugly. Then, I put only the manifest.json in project_folder/public/build but the app.####.cs and app.###.js is kept in the public_html/build/assets. And now it is working fine. Hope this help someone like me, even though it might not be the right approach.

In laravel why the additional packages are stored in vendor directory?

I want to change the floder for additional installed package.How to change the floder path for additional installed packages.
Laravel is framework that depends on many other packages that has been built by the best in the PHP world and makes use of a dependency management tool called composer.
For Laravel to work her magic, she needs the help of composer to download all those codes that has gone through the test of time to assist her. composer would then place all of these codes into a folder specifically tailored for them which is the /vendor folder.
It seems that you need the power of some other codes to help you in your project. If that's the case, you might want to check out composer first for some basics before starting a new Laravel project.
You might want to check this video on https://laracasts.com to get a bigger picture as to how all of these things piece together.
Update
If you need to change the /vendor directory, you can simply change them in your composer.json.
"config": {
"vendor-dir": "new-vendor-dir-name"
}

Laravel symlink to separate repo and framework

I wrote a web app in Laravel. The repo doesn't store a whole Laravel installation - it only has app and public directories.
I'm trying to figure out a good solution to allow other devs to easily spin up a local version of my code for them to try/work on. Someone suggested that I set up a symlink between the cloned repo and my Laravel installation, which sounded like a good solution to me (allows them to push/pull from my repo without needing to copy files endlessly).
However, when I set up the symlink, Laravel starts looking for its files (bootstrap, vendor, etc.) in the repo's directory, but they don't exist there, so I just get a blank screen.
Any ideas?

Laravel 4 - Developing & deploying web application for other users

Although I'm new to Laravel 4, there has been one question on my mind since day one which I cannot seem to understand, nor find any information on.
My plan is to build an open source web application, which other users will be able to download and use on their own server. Now my current way of working is:
Install Laravel with composer
Add packages to composer than I need for the application
Start coding: editing files directly inside of app/ (global.php, routes, controllers, views, migrations etc).
Keep all of my assets within /public/assets/
This works fine for me, and I have no problems with it. However the question is:
How will I deploy the application to users if I build it this way? If they install Laravel via composer, all of the files within /app will be default (obviously), so how would I go about getting my edited + custom files into their install of Laravel?
Do I have to build the whole application as part of my own bundle? Or is there some kind of way composer can pacakge what I've done to solve this problem I can see happening?
I'm just throwing words out, if someone could explain and point me in the right direction that would be great.
Thanks.
You can just chuck all your files on github. You dont need to include composer. People can download composer and run it from the install directory (or if they have it globally run it from there)
If you run a composer install with laravel 4 only, it will download all fresh. In your case you just have all the library's in place already. So for future updates you as a developer can easilly upgrade to a newer version. The "users" can simply say "git pull" to update their instance. You still need composer to do your initial install (db seed, post install steps etc)
At least that is my point of view. Just look at a simple laravel 4 bootstrap example https://github.com/andrew13/Laravel-4-Bootstrap-Starter-Site it also holds all the files.

Resources