Uploading a reactjs code in github, without the node_modules folder - node.js

I want to upload a react app in github. But, I dont want to HOST IT. I only want to keep the codes there. But while uploading, I had problem with uploading the node_modules folder. I searched other repo, and even there node_modules folder wasn't present. Still their code could be used by running a command called npm install or something similar to that.
What are the steps to upload My ReactJS Code without uploading the node_modules. But in such a way, by which anyone can install all the node modules by npm install or something similar to that?

To tell git to exclude something in your project, you use a .gitignore file. In the .gitignore file, you can add patterns to files or folders and git will not track any of those files.
Here is a template for Node projects given by GitHub. It excludes the node_modules folder. Put it in your project root and remember to rename it to just .gitignore (note the period in front).

Related

How can a (vue/vite) (node/express) share same .env and node_modules files and foolder structure?

How to make vue (npm init vue#latest) and node/express server/api in root folder in a way that there are no duplicate
folders and files, like node_modules, .env files, etc.
Plan is to build client(spa) to public folder inside server(api), so everything is neat!
Is that usual practice?
I tried usual approach to generate everything separately, but no success in telling vite to install dependencies in node_modules outside client folder.

How to properly install dependencies in large projects?

I am a dev on a team inside a very large project. This is the first time I have worked on a project where the node_modules/package-lock files are not in the root of the project. I am used to personal projects with a few folders, files, and the node_modules/package-lock in the root so I can always easily "npm install..." in the root.
I am running into an issue when I try to run npm install (package), it completely breaks my local project. I have to rollback the changes, rebuild, and it works fine again.
Things I have tried:
Navigate to the same directory that node modules is in.
Example: C:\Users\USERID\source\repos\companyName\companyName2\Web\Administration.
Node_modules and package-lock are located here along with ~20 other various folders.
Navigate to the root (even though node_modules isn't located here, figured I'd try).
Navigate to one folder above. I tried this because this is the directory where the Visual Studio .sln file is located.
Example: C:\Users\USERID\source\repos\companyName\companyName2\Web\companyName.Web.Administration.sln
For more context, the specific file I need to add a package to is: C:\Users\USERID\source\repos\companyName\companyName2\Web\Administration\ClientApp\app\letter\letter-create-main.component.ts
I am hoping I can get some clarity on how to properly run npm install in large projects so I can add packages that I need to this monster of a project, and hopefully help others that have this question at the same time!

How to create new angular app without downloading node_modules files

I'm new in angular and every time I want to create new angular application it downloads approximately 316MB files from internet.
I was wondering if there is any way to skip downloading node_modules folder and just download other angular files neccessary to run my app and then copy&paste my (existing) node_modules folder to root folder of my app.
you can run the command ng new <YourProjectName> --skip-install, It will create a package without node_modules folder.
Yes, it's possible. Copy package.json, package-lock.json and node_modules. node_modules usually doesn't contain any project specific files or configurations.

How to commit NPM module Names to git without the actual files so that they can get rebuilt at the other end?

I'm developing a node project which depends on several npm modules. What I'm currently doing is committing all those modules to my git repository, pulling on my server, and then rebuilding the modules on the other end because the system architectures are different. What I would like to do instead, is just commit enough stuff so that npm knows what it needs to rebuild, and nothing more.
I would hoping I could do this without actually committing all the module files. I know little about npm's internals, but see that every module has a package.json file, is this all that npm will need? And if that's the case, how would I go about ignoring all files in my node_modules folder except the package.json files?
Thanks.
Why can't you just have a package.json file in your main application root listing all your dependencies? This file should then be the only thing checked in to source control.
At build time or when other developers pull the code, npm install should be run from the same directory that has your package.json file. It will then pull down all your dependencies locally.

Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js

When I try to upload my Node.js project on Elastic Beanstalk I obtain the following error:
Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js.
However, I have the package.json in the main directory.
A couple of people were zipping the parent folder incorrectly. You need to select all the contents of the folder and zip those.
https://forums.aws.amazon.com/message.jspa?messageID=477087
https://forums.aws.amazon.com/thread.jspa?threadID=130140&tstart=0
While uploading the .zip file (Nodejs application) we need to select all the files in the folder, then zip it as shown in below screenshot.
Then upload the Nodejs(zip file) project in AWS Elastic Beanstalck.
I had the same issue running a zip of node js boilerplate. It worked when I removed .git and .idea directories and n.gitignore file from the zip.
You need to zip the build directory, to do so inside that directory you can zip -r upload.zip . (do not forget the dot at the end for current directory).
So in that directory you need to have your index.js or server.js as EB looks for how to run the app in the directory only and will not look into folders src, dist etc.
This can be the packaging issue. You will need to go inside the project and compress altogether as provided in the screenshot:
If you use eb cli, make sure you have git committed all the changes.
If you do zip and upload, make sure you don't zip the parent folder but selecting all files and zip.
In my case i have found a wrong copy of the folder .elasticbeanstalk with inside another config.yml
example
root_project_folder
.elasticbeanstalk/
config.yml
public/
.elasticbeanstalk/
config.yml
and when I started the "eb deploy" command it failed because use the wrong public/ folder as a ROOT
removing the public/.elasticbeanstalk/ have resolved my issue
Ciao

Resources