npm react安裝報(bào)錯(cuò)的解決辦法:1、打開項(xiàng)目中的“package.json”文件,找到dependencies對象;2、將其中的“react.json”移動到“devDependencies”;3、在終端中運(yùn)行“npm audit --production”即可修復(fù)警告。
本教程操作環(huán)境:Windows10系統(tǒng)、react18.0.0版、Dell G3電腦。
npm react 安裝報(bào)錯(cuò)怎么辦?
npm安裝react時(shí)提示報(bào)錯(cuò)
在使用npx create-react-app的安裝過程中出現(xiàn)了
6 high severity vulnerabilities
但是后續(xù)仍然顯示成功安裝,按照提示輸入npm-audit時(shí)候卻報(bào)錯(cuò)
npm audit fix npm ERR! code ENOLOCK npm ERR! audit This command requires an existing lockfile. npm ERR! audit Try creating one first with: npm i --package-lock-only npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\christine\AppData\Local\npm-cache\_logs\2022-10-10T08_34_39_142Z-debug-0.log
后續(xù)發(fā)現(xiàn)是自己把項(xiàng)目的路徑輸錯(cuò)了,正確輸入項(xiàng)目路徑時(shí)顯示提示漏洞的原因
nth-check <2.0.1 Severity: high Inefficient Regular Expression Complexity in nth-check - https://github.com/advisories/GHSA-rp65-9cf3-cjxr fix available via `npm audit fix --force` Will install react-scripts@2.1.3, which is a breaking change node_modules/svgo/node_modules/nth-check css-select <=3.1.0 Depends on vulnerable versions of nth-check node_modules/svgo/node_modules/css-select svgo 1.0.0 - 1.3.2 Depends on vulnerable versions of css-select node_modules/svgo @svgr/plugin-svgo <=5.5.0 Depends on vulnerable versions of svgo node_modules/@svgr/plugin-svgo @svgr/webpack 4.0.0 - 5.5.0 Depends on vulnerable versions of @svgr/plugin-svgo node_modules/@svgr/webpack react-scripts >=2.1.4 Depends on vulnerable versions of @svgr/webpack node_modules/react-scripts 6 high severity vulnerabilities
一個(gè)建議:忽略
npm提示可以使用`npm audit fix --force`進(jìn)行修復(fù),但是Don't be alarmed by vulnerabilities after NPM Install (voitanos.io)j
建議是忽略這些錯(cuò)誤;因?yàn)閚pm只是包管理工具,他不能夠解決包自身的缺陷和漏洞,如果強(qiáng)制修復(fù)解決的話,很有可能會引起更為嚴(yán)重的錯(cuò)誤。
一定要嘗試解決的話
打開項(xiàng)目中的package.json文件,找到dependencies對象
"dependencies":{ //……}
將其中的react.json移動到devDependencies(沒有的話可以自己創(chuàng)建一個(gè)),你的版本可能與我的不同,但是這是無關(guān)緊要的,只需要移動即可
"devDependencies": { "react-scripts": "5.0.1" },
最后,在終端中運(yùn)行npm audit --production,即可修復(fù)警告
推薦學(xué)習(xí):《react視頻教程》
The above is the detailed content of What to do if npm react installation error occurs. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Netflixusesacustomframeworkcalled"Gibbon"builtonReact,notReactorVuedirectly.1)TeamExperience:Choosebasedonfamiliarity.2)ProjectComplexity:Vueforsimplerprojects,Reactforcomplexones.3)CustomizationNeeds:Reactoffersmoreflexibility.4)Ecosystema

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.

Netflix uses React as its front-end framework. 1) React's componentized development model and strong ecosystem are the main reasons why Netflix chose it. 2) Through componentization, Netflix splits complex interfaces into manageable chunks such as video players, recommendation lists and user comments. 3) React's virtual DOM and component life cycle optimizes rendering efficiency and user interaction management.

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 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.

The advantages of React are its flexibility and efficiency, which are reflected in: 1) Component-based design improves code reusability; 2) Virtual DOM technology optimizes performance, especially when handling large amounts of data updates; 3) The rich ecosystem provides a large number of third-party libraries and tools. By understanding how React works and uses examples, you can master its core concepts and best practices to build an efficient, maintainable user interface.

Netflix mainly uses React as the front-end framework, supplemented by Vue for specific functions. 1) React's componentization and virtual DOM improve the performance and development efficiency of Netflix applications. 2) Vue is used in Netflix's internal tools and small projects, and its flexibility and ease of use are key.

React is a front-end framework for building user interfaces; a back-end framework is used to build server-side applications. React provides componentized and efficient UI updates, and the backend framework provides a complete backend service solution. When choosing a technology stack, project requirements, team skills, and scalability should be considered.
