i installed yarn/webpack and after that npm crashed! I get the following error:
npm -v
node:internal/modules/cjs/loader:928
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:925:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:997: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:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813: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' ]
}
The error appears whatever I like to do with npm. I'm working on Mac OSX 10.14.6
Node Version: 15.4.0
Yarn Version: 1.22.10
thanks for help.
This happened to me when I used brew install node. I fixed it by doing brew uninstall node (just to clean up) and then installing nodejs by downloading the package from https://nodejs.org/
Just uninstall using brew uninstall node, download and install package from https://nodejs.org.
Related
When I try and run my mocha tests I get
$ npm t
> digitalAlarmClock#1.0.0 test /home/durrantm/Dropnot/code/js/mochaChai/digitalAlarmClock
> mocha *.test.js
internal/modules/cjs/loader.js:979
throw err;
^
Error: Cannot find module 'commander'
Require stack:
- /usr/lib/nodejs/mocha/bin/_mocha
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/usr/lib/nodejs/mocha/bin/_mocha:10:17)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/lib/nodejs/mocha/bin/_mocha' ]
}
npm ERR! Test failed. See above for more details.
How to fix?
here's how I solve the issue:
run npm list to see if there's any dependency missing, for example, I saw:
[root#d21b188bb7e1 configurable-http-proxy]# npm list
configurable-http-proxy#4.3.2 /srv/configurable-http-proxy
├── UNMET DEPENDENCY commander#~7.2.0
...
install it manually by
npm install --save commander#~7.2.0
This can happen for several different reasons.
In this case it is because mocha isn't installed.
Fix with
npm install --save-dev mocha
previously node was working properly.
After that as i wanted to install express & socket.io.
it asked for node version update.
i tried to update node version & i believe i forgot some command to run in updation process.
now it's giving following error on any npm command. even if i type only npm, that'll give error.
m#m-Lenovo-ideapad-320-15IKB:/var/www/html/chat$ npm -v
nternal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Finally it got solved, i think following process worked.
deleted npm module from usr folder
I removed npm module
cleared the cache
installed npm
& it worked
The mistake i was doing was not clearing the cache
After upgrading expo-cli to the latest version. I tried starting my app with 'expo start' but I got this error
C:\Users\DevLewa\Desktop\app\AgroSprite>expo
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'split-string'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous>
(C:\Users\DevLewa\AppData\Roaming\npm\node_modules\exp
o-cli\node_modules\braces\lib\utils.js:3:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
How do I fix this please?
rollback to version 2.4.3
npm install -g expo-cli#2.4.3
I installed the missing module using
npm install -g split-string
and it worked.
I faced the same problem . I uninstalled expo-cli and nodejs and installed again. It works for me.
I am using MacOS High Sierra(10.13.5).
When I run npm command, e.g. npm -v, I constantly get this error:
module.js:471
throw err;
^
Error: Cannot find module 'buffer-shims'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:36:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
I tried the following solution, which I found after googling:
rm -r node_modules; rm package-lock.json; npm install
I succeeded at removing the node_modules folder, but I can't find a package-lock.json file and I still get the same error.
How do I resolve the npm error I am encountering?
No idea if this is still necessary, but for future reference: I encountered the same problem and was able to fix it.
What I did was just reinstall nodejs (11.1.0 at the time of writing) and then all npm commands were working again. I think for some odd reason the nodejs/npm install got fubar and kept on throwing the aforementioned errors.
I am getting this error while running gulp, I already have babel-register installed.
[18:51:21] Requiring external module babel-register
module.js:327
throw err;
^
Error: Cannot find module './_baseIsRegExp'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\ndbsite\src\NdbSite.UI\node_modules\babel-plugin-transform-class-properties\node_modules\babel-helper-function-name\node_modules\babel-types\node_modules\lodash\isRegExp.js:1:82)
at Module._compile (module.js:409:26)
at Module._extensions..js (module.js:416:10)
at Object.require.extensions.(anonymous function) [as .js] (D:\ndbsite\src\NdbSite.UI\node_modules\babel-register\lib\node.js:156:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
seems I am missing some package. Not sure how to find it. Please Help.
The issue I was facing because of old packages referenced inside other Modules were not updated
As suggested by #loganfsmyth in comment. I updated node & npm. Still issue exists since old packages were not updated inside the hierarchy.
Resolution is to delete old folders using rimraf and then npm install with new node & npm :
npm install rimraf -g
rimraf node_modules
npm install