NPM ERROR, NEXT.JS ERROR can not use npm run dev - node.js

> # dev C:\Users\Mustafa\Desktop\React&Next\insta-2.0
> next dev
'Next\insta-2.0\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'C:\Users\Mustafa\Desktop\next\dist\bin\next'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Mustafa\AppData\Roaming\npm-cache\_logs\2021-10-13T15_27_45_466Z-debug.log
I am using npm run dev and it gives me this error and I don't understand what this error is about if any of you could help me solve this I would really appreciate it

Go to the root directory of Your next project and run this commands in terminal:
npm install next react react-dom
after
npm run dev
Or if You are using VSCode open Your next project in Visual Studio Code, run the integrated terminal (Ctrl+`) and enter the above commands.
It's should works now ;-)

Related

Not able to start react application - ENOENT: no such file or directory, but its NOT package.json file(The file is present)

I am new to react and I was following the official documentation in order to create my first react app - https://reactjs.org/docs/create-a-new-react-app.html
The commands are simple, I have read many post in many forums but I didn't see someone having this problem.
So I installed node.js with version 14.18.0 LTS which is OK as per the documentation in react (Node >= 14.0.0 and npm >= 5.6). Then I ran the 3 commands again from the documentation:
npx create-react-app my-app
cd my-app
npm start
First two commands are executed successfully, but when I run npm start it fails with the following error:
$ npm start
> my-app#0.1.0 start F:\Programming\my_location\my-app
> react-scripts start
internal/fs/utils.js:259
throw err;
^
Error: ENOENT: no such file or directory, lstat 'C:\Users\streetzaki96\AppData\Local\Temp;F:'
at Object.realpathSync (fs.js:1646:7)
at Object.<anonymous> (F:\Programming\my_location\my-app\node_modules\temp-dir\index.js:9:13)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (F:\Programming\my_location\my-app\node_modules\tempy\index.js:5:17)
at Module._compile (internal/modules/cjs/loader.js:1185:30) {
errno: -4058,
syscall: 'lstat',
code: 'ENOENT',
path: 'C:\\Users\\streetzaki96\\AppData\\Local\\Temp;F:'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\streetzaki96\AppData\Roaming\npm-cache\_logs\2021-10-05T21_31_51_222Z-debug.log
The machine which I am trying to run the code is with Windows 8.1 Pro. I also tried running the same commands on another machine which is with Windows 10 and I don't get any error there.
I tried running npm with verbose npm start --verbose to see if I can see something in the log file, but it is the same error message just with more lines of code.

I get these errors when I use the ```npm run dev``` command

Error: Cannot find module 'This is the Folder path \bin\webpack.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47* {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `webpack serve --config ./bundler/webpack.dev.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\21697\AppData\Roaming\npm-cache\_logs\2021-09-20T20_54_58_070Z-debug.log
PS C:This is the Folder path>
PS: I did delete both the package-lock & node_modules and reinstalled npm using npm install
but the problem still exists, I also tried reinstalling node js, same thing
Error: Cannot find module 'This is the Folder path \bin\webpack.js'
It's looking for a module with name/path 'This is the Folder path \bin\webpack.js'. That doesn't look like a valid module name/path.
Looks like you added some debug text somewhere you shouldn't have.
Hard to come up with other explanations since you did not post any of the code.
I finally solved it by reinstalling both node js & npm and instlalling chokidar 3 using the command npm i chokidar#3.0.0 it turns out that the previous version does not support node js 14+

Problem when running sass after installation

THE PROBLEM
I'm trying to run sass as part of a course I'm doing. However, when inputting the following command:
PS H:\Qubo\LEARNING\HTML & CSS\CSS\sass_sandbox> npm run sass
I get this:
> node-sass -w scss/ -o dist/css/ --recursive
'CSS\CSS\sass_sandbox\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'H:\Qubo\LEARNING\node-sass\bin\node-sass'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sass_sandbox#1.0.0 sass: `node-sass -w scss/ -o dist/css/ --recursive`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sass_sandbox#1.0.0 sass script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\My Name\AppData\Roaming\npm-cache\_logs\2020-11-08T20_44_40_258Z-debug.log```
I found a solution to my problem, albeit I don't exactly know how it works.
SOLUTION:
Looking at the code, I noticed that it had a problem finding a folder, which was not in the folder is what looking for.
It was looking in 'C' when my folder was in H (a separate hard drive).
I moved it to the desktop (inside 'C') and presto, it worked.

Npm start not working after running create-react-app ONLY in Documents directory

I've been battling this issue all day and still cannot figure out what I am missing. I've always created my projects under the Documents directory on my computer but I've started getting the following error when trying to start a project after using create-react-app.
my-app#0.1.0 start C:\Users\{user}\Documents\B&R Fun\nginx_test_deploy\my-app
react-scripts start
'R' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'C:\Users\{user}\Documents\react-scripts\bin\react-scripts.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\{user}\AppData\Roaming\npm-cache\_logs\2020-03-30T21_02_14_553Z-debug.log
Interestingly, running the exact same commands on my desktop creates an app without errors. Is there some configuration I'm missing that could impact apps created under the 'Documents' folder?
You should try to clear and re-install node_modules. You can do this by running the following command.
rm -rf node_modules package-lock.json && npm install && npm start
Also, upgrade to a later version of node and npm.
Try to rename B&R Fun folder to avoid ampersand there. It seems that & breaks everything. See this issue

npm start not working for my react project

So I'm trying to run the npm start on a react project I made in command line so that I can run the browser sync and see my progress as I work on it.
However, I keep getting this result whenever I try to run it.
module.js:538
throw err;
^
Error: Cannot find module '/Users/Sam/Library/Mobile Documents/com~apple~CloudDocs/Work/BookStore/Home attempts/Routing/2-react-router/lib/server.js'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-tutorials#0.0.0 start: `node lib/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-tutorials#0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Sam/.npm/_logs/2017-11-30T20_10_07_869Z-debug.log
I'm not sure what's going on as I'm not an expert on react/node/npm, rather a reluctant amateur.
Can anyone help?
When you execute npm start, a command node lib/server.js is called. Command is defined in package.json
"scripts": {
"start": "node lib/server.js"
}
Looking from the error post it looks that server.js file is missing in lib folder.

Resources