search
HomeWeb Front-endFront-end Q&AWhat does executing the command on the command line mean to initialize the vue project?

Executing the command "vue init webpack vue-project" on the command line means initializing the vue project. This command means initializing the "vue-project" project based on webpack; where "vue-project" refers to the user's own The defined project name. The project name cannot use uppercase letters.

What does executing the command on the command line mean to initialize the vue project?

The operating environment of this tutorial: windows10 system, vue3 version, DELL G3 computer.

VUE project initialization step command

1, install Node.js;

Window installation package Mac installation package
Check whether the installation is successful node -v
If the version is displayed, it is successful, as shown in the figure:

What does executing the command on the command line mean to initialize the vue project?

2 , install the vue-cli scaffolding;

Open the command line window cmd (window R, enter cmd and then Enter)

Execute the command under cmdcnpm install vue-cli - g

The installation is successful as shown in the figure

What does executing the command on the command line mean to initialize the vue project?

3, initialize the project folder;

After you prepare Open the cmd folder where the project was built and execute the command vue init webpack vue-project(Note: vue-project is a custom project name, the project name cannot use capital letters)

As shown in the picture:

What does executing the command on the command line mean to initialize the vue project?

After the initialization is completed, as shown in the figure:

What does executing the command on the command line mean to initialize the vue project?

The successful startup of the project is shown in the figure:

What does executing the command on the command line mean to initialize the vue project?

The page effect after successful startup is as follows:

What does executing the command on the command line mean to initialize the vue project?

Other details to be added:

1, the command line tool I use is Git, the following is the latest installation package link
Window installation package

2, http://localhost:8081/ in the address bar #/ How to remove the # sign behind it

Open the project in the editor, find index.js under router under src in the directory, open it, and change the mode to mode:'history' as shown in the picture:

What does executing the command on the command line mean to initialize the vue project?

3. After starting the project, there is no need to copy and paste the address. That is, after running npm run dev, the page will automatically open in the browser.

Open the project in the editor and find index.js under config. Find autoOpenBrowser: false, line 18 below. Just change false to true. As shown in the picture:

What does executing the command on the command line mean to initialize the vue project?

When creating a new branch and configuring routing, pay attention to the path:

What does executing the command on the command line mean to initialize the vue project?

4. Style

What does executing the command on the command line mean to initialize the vue project?

less_loader depends on less, both need to be installed, which can be installed in the project dependencies (vue ui) or terminal installation;
If the following error occurs, it means there is no installation style rely.

1What does executing the command on the command line mean to initialize the vue project?

Terminal installation style dependency:

  • If it is regular, execute npm install stylus-loader css-loader style-loader - -save-dev just install the dependencies

  • If it is less, execute npm install less less-loader --save-dev to install the dependencies.

  • If it is sass, just execute npm install sass sass-loader --save-dev to install the dependencies. Or ($npm intall sass-loader --save; $npm install node-sass --save)

When installing the latest version of less-loader, the vue project prompts an error: Failed to compile with 1 errors

ERROR  Failed to compile with 1 errors                                 14:20:44
 error  in ./src/components/HelloWorld.vue
Module build failed: TypeError: loaderContext.getResolve is not a function
    at createWebpackLessPlugin (D:\work\vue3.0\gcmmobile\node_modules\less-loader\dist\utils.js:31:33)
    at getLessOptions (D:\work\vue3.0\gcmmobile\node_modules\less-loader\dist\utils.js:148:31)
    at Object.lessLoader (D:\work\vue3.0\gcmmobile\node_modules\less-loader\dist\index.js:27:49)
 @ ./node_modules/vue-style-loader!./node_modules/css-loader/dist/cjs.js?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-469af010","scoped":true,"hasInlineConfig":false}!./node_modules/less-loader/dist/cjs.js?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/components/HelloWorld.vue 4:14-378 14:3-18:5 15:22-386
 @ ./src/components/HelloWorld.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js1234567891011121314

is a version problem. The solution is to lower the less-loader version. My vue version is 2.5.2.

Uninstall the latest version first

yarn remove less-loader
npm uninstall less-loader123

Install the less-loader 5.0.0 version

yarn add less-loader@5.0.0
npm install less-loader@5.0.0 -D123

5.npm ERR! code ERESOLVE:

Error when running npm install:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: operatingsystem@0.1.0
npm ERR! Found: vue@3.1.5
npm ERR! node_modules/vue
npm ERR!   vue@"^3.0.0" from the root project
npm ERR!12345678

Console input npm -V found that my npm version is 7.x, because npm7.x The version is stricter on some commands than npm6.

2) Using npm6.x

Tips: There is no need to uninstall npm@7 when using npm@6. You can use npx to specify the version of npm. For example: npx -p npm@6 npm i --legacy-peer-deps

If this doesn't work immediately, you can delete node_modules and package-lock.json

first

Related recommendations: vue.js video tutorial

The above is the detailed content of What does executing the command on the command line mean to initialize the vue project?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
React: The Foundation for Modern Frontend DevelopmentReact: The Foundation for Modern Frontend DevelopmentApr 19, 2025 am 12:23 AM

React is a JavaScript library for building modern front-end applications. 1. It uses componentized and virtual DOM to optimize performance. 2. Components use JSX to define, state and attributes to manage data. 3. Hooks simplify life cycle management. 4. Use ContextAPI to manage global status. 5. Common errors require debugging status updates and life cycles. 6. Optimization techniques include Memoization, code splitting and virtual scrolling.

The Future of React: Trends and Innovations in Web DevelopmentThe Future of React: Trends and Innovations in Web DevelopmentApr 19, 2025 am 12:22 AM

React's future will focus on the ultimate in component development, performance optimization and deep integration with other technology stacks. 1) React will further simplify the creation and management of components and promote the ultimate in component development. 2) Performance optimization will become the focus, especially in large applications. 3) React will be deeply integrated with technologies such as GraphQL and TypeScript to improve the development experience.

React: A Powerful Tool for Building UI ComponentsReact: A Powerful Tool for Building UI ComponentsApr 19, 2025 am 12:22 AM

React is a JavaScript library for building user interfaces. Its core idea is to build UI through componentization. 1. Components are the basic unit of React, encapsulating UI logic and styles. 2. Virtual DOM and state management are the key to component work, and state is updated through setState. 3. The life cycle includes three stages: mount, update and uninstall. The performance can be optimized using reasonably. 4. Use useState and ContextAPI to manage state, improve component reusability and global state management. 5. Common errors include improper status updates and performance issues, which can be debugged through ReactDevTools. 6. Performance optimization suggestions include using memo, avoiding unnecessary re-rendering, and using us

Using React with HTML: Rendering Components and DataUsing React with HTML: Rendering Components and DataApr 19, 2025 am 12:19 AM

Using HTML to render components and data in React can be achieved through the following steps: Using JSX syntax: React uses JSX syntax to embed HTML structures into JavaScript code, and operates the DOM after compilation. Components are combined with HTML: React components pass data through props and dynamically generate HTML content, such as. Data flow management: React's data flow is one-way, passed from the parent component to the child component, ensuring that the data flow is controllable, such as App components passing name to Greeting. Basic usage example: Use map function to render a list, you need to add a key attribute, such as rendering a fruit list. Advanced usage example: Use the useState hook to manage state and implement dynamics

React's Purpose: Building Single-Page Applications (SPAs)React's Purpose: Building Single-Page Applications (SPAs)Apr 19, 2025 am 12:06 AM

React is the preferred tool for building single-page applications (SPAs) because it provides efficient and flexible ways to build user interfaces. 1) Component development: Split complex UI into independent and reusable parts to improve maintainability and reusability. 2) Virtual DOM: Optimize rendering performance by comparing the differences between virtual DOM and actual DOM. 3) State management: manage data flow through state and attributes to ensure data consistency and predictability.

React: The Power of a JavaScript Library for Web DevelopmentReact: The Power of a JavaScript Library for Web DevelopmentApr 18, 2025 am 12:25 AM

React is a JavaScript library developed by Meta for building user interfaces, with its core being component development and virtual DOM technology. 1. Component and state management: React manages state through components (functions or classes) and Hooks (such as useState), improving code reusability and maintenance. 2. Virtual DOM and performance optimization: Through virtual DOM, React efficiently updates the real DOM to improve performance. 3. Life cycle and Hooks: Hooks (such as useEffect) allow function components to manage life cycles and perform side-effect operations. 4. Usage example: From basic HelloWorld components to advanced global state management (useContext and

React's Ecosystem: Libraries, Tools, and Best PracticesReact's Ecosystem: Libraries, Tools, and Best PracticesApr 18, 2025 am 12:23 AM

The React ecosystem includes state management libraries (such as Redux), routing libraries (such as ReactRouter), UI component libraries (such as Material-UI), testing tools (such as Jest), and building tools (such as Webpack). These tools work together to help developers develop and maintain applications efficiently, improve code quality and development efficiency.

React and Frontend Development: A Comprehensive OverviewReact and Frontend Development: A Comprehensive OverviewApr 18, 2025 am 12:23 AM

React is a JavaScript library developed by Facebook for building user interfaces. 1. It adopts componentized and virtual DOM technology to improve the efficiency and performance of UI development. 2. The core concepts of React include componentization, state management (such as useState and useEffect) and the working principle of virtual DOM. 3. In practical applications, React supports from basic component rendering to advanced asynchronous data processing. 4. Common errors such as forgetting to add key attributes or incorrect status updates can be debugged through ReactDevTools and logs. 5. Performance optimization and best practices include using React.memo, code segmentation and keeping code readable and maintaining dependability

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools