Error when running npm, Cannot find module 'semver' - node.js

I just installed npm and nodejs. However, after updating nodejs, running npm givesd me this error:
node:internal/modules/cjs/loader:1063
throw err;
^
Error: Cannot find module 'semver'
Require stack:
- /usr/share/npm/lib/utils/unsupported.js
- /usr/share/npm/bin/npm-cli.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1060:15)
at Module._load (node:internal/modules/cjs/loader:905:27)
at Module.require (node:internal/modules/cjs/loader:1127:19)
at require (node:internal/modules/helpers:112:18)
at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
at Module._compile (node:internal/modules/cjs/loader:1246:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1300:10)
at Module.load (node:internal/modules/cjs/loader:1103:32)
at Module._load (node:internal/modules/cjs/loader:942:12)
at Module.require (node:internal/modules/cjs/loader:1127:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/share/npm/lib/utils/unsupported.js',
'/usr/share/npm/bin/npm-cli.js'
]
}
Node.js v19.5.0
How can I fix that? After uninstalling nodejs and npm (and then reinstalling them) it still doesn't work.
OS: Deepin 23

I cant comment yet so im writing here. did you run the command npm install -g semver

Related

why does npm start fail?

I am trying to run some React code but receiving this error on vs code. I am not sure what the issue is.
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'parseurl'
Require stack:
- C:\Users\hp\Desktop\Programming\Projects\apexgrade\node_modules\finalhandler\index.js
- C:\Users\hp\Desktop\Programming\Projects\apexgrade\node_modules\express\lib\application.js
- C:\Users\hp\Desktop\Programming\Projects\apexgrade\node_modules\express\lib\express.js
- C:\Users\hp\Desktop\Programming\Projects\apexgrade\node_modules\express\index.js
- C:\Users\hp\Desktop\Programming\Projects\apexgrade\node_modules\webpack-dev-server\lib\Server.js
- C:\Users\hp\Desktop\Programming\Projects\apexgrade\node_modules\react-scripts\scripts\start.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\hp\Desktop\Programming\Projects\apexgrade\node_modules\finalhandler\index.js:18:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\hp\\Desktop\\Programming\\Projects\\apexgrade\\node_modules\\finalhandler\\index.js',
'C:\\Users\\hp\\Desktop\\Programming\\Projects\\apexgrade\\node_modules\\express\\lib\\application.js',
'C:\\Users\\hp\\Desktop\\Programming\\Projects\\apexgrade\\node_modules\\express\\lib\\express.js',
'C:\\Users\\hp\\Desktop\\Programming\\Projects\\apexgrade\\node_modules\\express\\index.js',
'C:\\Users\\hp\\Desktop\\Programming\\Projects\\apexgrade\\node_modules\\webpack-dev-server\\lib\\Server.js',
'C:\\Users\\hp\\Desktop\\Programming\\Projects\\apexgrade\\node_modules\\react-scripts\\scripts\\start.js'
]
}
i have tried using npm install, but that doesnt seem to solve the problem
I think your package-lock.json don't have parseurl package. Since parseurl is dependency of express. Try to install parseurl with command.
run step by step follow bellow command.
npm uninstall express
npm install express
or npm install parseurl

I got following error while developing in MEAN stack : Cannot find module 'mongojs'

I ran command: node server in bash on Ubuntu and below is the error I got:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'mongojs'
Require stack:
- /home/nishil/Documents/contactListApp/server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/nishil/Documents/contactListApp/server.js:5:15)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/nishil/Documents/contactListApp/server.js' ]
}
How can I resolve this error?
Please check in your package.json file if mongojs is installed or not.
If it is then remove package-lock.json and remove node_modules folder and install node modules again by npm i.
If mongojs is not installed then you can do that using npm i mongojs command
But i would suggest please change your package from mongojs to mongodb https://www.npmjs.com/package/mongodb
As mongojs is seems outdated its not updated since last 3 years it has 27 open issues since very long.
Let me know if this solutions works for you..
If you want to use mongojs or any other module, please make sure it's there in package.json and you have run yarn install or npm install in that directory containing the package.json. If the problem still persists, try deleting the node_modules folder in this directory and try running yarn install or npm install again.

Error: Cannot find module 'react-dev-utils/WatchMissingNodeModulesPlugin'

I have React.js application with the connection of Rust. Problem is about running the application. When I try to run npm start it return this error:
throw err;
^
Error: Cannot find module 'react-dev-utils/WatchMissingNodeModulesPlugin'
Require stack:
- /Users/elchinfarhad/Desktop/IndoorNavigation/react-client/config/webpack.config.js
- /Users/elchinfarhad/Desktop/IndoorNavigation/react-client/scripts/start.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/elchinfarhad/Desktop/IndoorNavigation/react-client/config/webpack.config.js:19:39)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/elchinfarhad/Desktop/IndoorNavigation/react-client/config/webpack.config.js',
'/Users/elchinfarhad/Desktop/IndoorNavigation/react-client/scripts/start.js'
]
}
Point is it was working before and I did not change anything, but later when I try npm start it return the above error. I try to delete node_modules and package-lock.json and install again but nothing changes. Can someone please help how can I solve this problem.
I encountered the same problem. It is probably about your npm version. I downgraded my npm version to 6.14.11, and the problem was solved.
npm install -g npm#6.14.11

npm start (yarn start) error. cannot find #babel/register

I creact app using react. I usually use yarn start to run my app.
Error messege is "cannot find #babel/register" but there is on the package.json.
In my package.json
"#babel/register": "^7.6.2"
my index.js
require('#babel/register');
module.exports = require('./server.js');
Error
> reactjs-simple-boilerplate#1.0.0 start
> node src/server/index.js
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module '#babel/register'
Require stack:
- /Users/mk/kr/kr-application-bd786050/kr-site/src/server/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/Users/mk/kr/kr-application-bd786050/kr-site/src/server/index.js:1:1)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/mk/kr/kr-application-bd786050/kr-site/src/server/index.js'
]
}
npm install --save-dev #babel/register is not works for me.
After run this code, I got npm ERR! code EINTEGRITY
Not sure I can help 100% with the given information, but try running the following:
rm -rf node_modules package-lock.json yarn.lock; npm i
That will not only remove your modules, but it'll also remove eventual lock files which are used as conformity for your module versions; It could happen they mismatched versions between installations causing the above error, thus by removing and reinstalling you should solve the problem.
If that's not the case, you might have something off on your package.json, which you'd need to share in order to debug further

How do i fix 'npm init' and not being able to upgrade it

I haven't touched node or coded in 3 years does anyone know how to fix this
npm init
node:internal/modules/cjs/loader:922
throw err;
^
Error: Cannot find module '../lib/cli.js'
Require stack:
- /usr/local/lib/node_modules/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
at Function.Module._load (node:internal/modules/cjs/loader:763:27)
at Module.require (node:internal/modules/cjs/loader:991:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:1)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/local/lib/node_modules/npm/bin/npm-cli.js' ]
}
i did
brew upgrade node
before this and tried
brew upgrade npm
and gives me
Warning: npm 15.3.0 already installed
I fix it by renaming the node_modules folder located in ''/usr/local/lib' and reinstalling node.js with the installer from nodejs.org which comes with npm
after that I ran rm -r noode_modules to remove the renamed copy of node_modules
not sure if deleting the folder was enough maybe I should have reinstalled all the old packages to overwrite whatever I had before and then removing it with npm uninstall to clean it up

Resources