Diagnosing Next.js installation process and failure and next build failure.
An installation process that worked in a breakdown
PRECHECK
a)Open permissions to avoid permission restriction and fail
b)If permission is an issue, set permission to Everybody, User etc. on your Windows or Mac
c) Check anti-virus issues(antivirus can block files)
INSTALLATION
- yarn global add create-next-app- (to make it accessible and to create binary )
- npm install -g npm@latest - (to make it ready for npm files _
- yarn create next-app peeapp - (create project )
- yarn global bin -(to check binary - check binary path)
- yarn global list - (check if the project exists in global list)
- create-next-app peeapp - (this is what creates the project)
PATH FIXES
- If you have path error, put the path of the project and the bin directory in the System Environment Variables both as a Users & System
- Check for the binary. Eg C:\Users\peema.yarn-global\bin, and you can place it in Path at the System or User Environment Variables
PROBLEM: NEXT BUILD REACT ERROR AND INSTALLATION ERRORS FOR NEXT BUILD
**However, there is an issue, next.js installs the project in the directory where you run the create-next-app command
(rightly so). but a problem with 'next build' occurs
Let's take the two path
a) C:\Users\peema\Documents\alert\peeapp\node_modules
b) C:\Users\peema\node_modules*
The project was installed in peeapp folder hence the node_modules (C:\Users\peema\Documents\alert\peeapp\node_modules) but (next build ) calls the second path (C:\Users\peema\node_modules )
So packages like react, next, and others cannot be found since they are not in the second path but were installed in the first.
SOLUTION:
Copy all packages that are not in the first node_modules to the second so that those packages can be found.