Encountered a problem with Next.js and React.js package installation errors causing installation failure
P粉426780515
2023-08-13 11:31:29
<p>Error: Several installation failures occurred during Next.js installation, including a missing package revealed during the build</p>
<blockquote>
<p>peema@DESKTOP-6UGCO8V MINGW64 ~/Documents/alert/peeapp $ next build
Module 'react' not found. Next.js requires you to include it in 'dependencies' of 'package.json'. To add it, run 'npm install
react' cannot find module 'react-dom'. Next.js requires you to include it in 'dependencies' of 'package.json'. To add it, run 'npm install react-dom' uncaughtException error: Module '@next/env' not found</p>
</blockquote><p><br /></p>
Diagnose Next.js installation process and failures and next build failures. An installation process that works in a crash
Preflight a) Open permissions to avoid permission restrictions and failures b) If permissions are an issue, set permissions to Everybody, User, etc. on Windows or Mac c) Check for anti-virus software issues (anti-virus software may block files)
Install
Path Repair
Problem: NEXT BUILD REACT ERROR and NEXT BUILD installation errors **However, there is a problem, next.js installs the project in the directory where the create-next-app command is run (Of course). But'next build'There is a problem
Let’s look at two paths a) C:\Users\peema\Documents\alert\peeapp\node_modules b) C:\Users\peema\node_modules*
The project is installed in the peeapp folder, so node_modules (C:\Users\peema\Documents\alert\peeapp\node_modules), but (next build) calls the second Paths (C:\Users\peema\node_modules)
So, packages like react, next and others cannot be found because they are not in the second path but are installed in the first path.
solution: Copy all packages that are not in the first node_modules to the second location so they can be found.