command line Flashcards
What does “npm run build” do?
“npm run build” is a command that triggers a script specified in the “scripts” section of the package.json file in a Node.js project. Typically, for a front-end project like a React application, this script creates a production-ready, optimized build of your application. The built files are typically output to a directory named “build” or “dist”.
“npm run build” is like telling your computer, “Hey, gather up all the code files for my website or app, tidy them up, and put them into a neat package that’s ready to go online for people to use.”
What does “sudo npm i -g serve” do?
This command tells your computer, “Please install a tool named ‘serve’ that helps me show my website on the internet. Use ‘sudo’ to get the necessary permissions, ‘npm i’ means install, ‘-g’ means make it available everywhere on my computer, and ‘serve’ is the tool we’re installing.”
What does “serve -s build -p 8000” do?
This command is like saying, “Use the ‘serve’ tool to show my website. Take the ‘build’ folder where my tidy, ready-to-go website package lives, and make it available on my computer at address ‘localhost’ and at port number ‘8000’ so I can check it out in my web browser.”
What does create-react-app my-app do?
This command creates a new React application with the name “my-app”. It sets up a new project with sensible defaults and best practices.
What does npm start do in a React application?
The npm start command launches the application in development mode and starts a server that will automatically refresh the page whenever you make changes to your code.
What does npm test do in a React application?
“npm test” starts the test runner which automatically runs any tests associated with your React application and watches for changes to rerun the tests.
What does npm install –save <library> do in a React application?</library>
npm install –save <library> adds a new library or package to your project and updates your package.json file. Replace <library> with the name of the library or package you want to add.</library></library>
What does npm run eject do in a React application?
npm run eject is specific to projects created with create-react-app. It removes the single build dependency and gives you full control over the project configuration and dependencies, allowing you to customize as per your requirements. Be careful though, this action is irreversible!
npm I -g create-react-app
Install global package create react app.