npm command : Cannot find module 'buffer-shims' - npm

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.

Related

Not able to run any npm command due to following error - Error: Cannot find module 'semver'

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

How to fix error "Cannot find module" using "expo start"

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.

react-native all commands failing

I tried upgrading react-native in a seperate branch and it caused some issues, so i reset everything and abandoned the branch. Currently on version: "react-native": "0.59.9",
Now when I try and run any command with react-native including react-native info I get the following error:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '../../tools/PackageManager'
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> (/home/_name_/solo/node_modules/#react-native-community/cli/build/commands/install/install.js:10:46)
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)
I tried several node versions using NVM.
Currently on 10.16.0 of node.
react-native appears to be working correctly when I create a new project and run commands
I have tried blowing away node_modules and package-json, locking down all versions of libraries, still no luck.
Seems it coudn't find the npm. Can you check the npm it is working in the same workspace and try to reinstall the react native commands with the same npm.
npm install -g react-native-cli

Cannot find module '_baseIsRegExp'

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

Cannot find module './packager/babelRegisterOnly'

This error probably has to do with package manager and happens when I run react-native start
Full Error:
module.js:340
throw err;
^
Error: Cannot find module './packager/babelRegisterOnly'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/amirsharif/mobile-rappad/node_modules/react-native/cli.js:11:1)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
I uninstalled react native with NPM then ran npm install react-native again and it worked. I cleared out everything in the node_modules folder.
Uninstall react-native fitst, then re-install it. It's work to me.