Home  >  Q&A  >  body text

Encountered a problem with Next.js and React.js package installation errors causing installation failure

<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>
P粉426780515P粉426780515455 days ago657

reply all(1)I'll reply

  • P粉792673958

    P粉7926739582023-08-14 09:42:51

    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

    1. yarn global add create-next-app-(make it accessible and create the binary)
    2. npm install -g npm@latest-(make it ready for npm files_
    3. yarn create next-app peeapp-(create project)
    4. yarn global bin-(check binary-check binary path)
    5. yarn global list-(check whether the item exists in the global list)
    6. create-next-app peeapp-(This is the content of the created project)

    Path Repair

    1. If you encounter a path error, please put the project path and bin directory into the user and system respectively in the system environment variables
    2. Check binary files. For example C:\Users\peema.yarn-global\bin and place it in the path of the system or user environment variable

    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.

    reply
    0
  • Cancelreply