I am working on a Reactjs project and was in the process of installing Electron. Every time I tried to install Electron globally I didn't have permission. I thought that by installing Homebrew I wouldn't run into this problem anymore. However, it created a bigger issue. I uninstalled homebrew to go back to my base. Now, every time I run NPM I get this error message:
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 had this problem on my Mac. When I was trying to update npm.
/usr/local/lib/node_modules was owned by root and not by me on my machine.
I did a sudo chown -R <username_here> /usr/local/lib/node_modules on that directory. Then I deleted the whole directory rm -r /usr/local/lib/node_modules and then did a brew uninstall npm and a brew reinstall npm to fix this issue.
Related
I'm getting the following error when trying to do anything with npm:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
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 /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
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)
I can't run npx create-react-app or any npm commands including uninstalling or updating npm. Yesterday I installed yarn, could that be part of the problem? I also updated my Mac to Catalina 10.15.5 recently. I'm not sure if either/both of these caused the npm issue or not.
What's causing this and how can I fix it?
Found a solution. A modified version of this answer worked.
I ran:
brew uninstall --force node
sudo rm -r /usr/local/lib/node_modules
brew install node
and that did the trick.
I'm setting up my dev environment on a fresh system. In my project folder:
npm install
npm run serve
And got this:
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/user/Documents/project/editor/src/main.js: Cannot find module '#babel/compat-data/corejs3-shipped-proposals'
Require stack:
- /Users/user/Documents/project/editor/node_modules/#babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
- /Users/user/Documents/project/editor/node_modules/#babel/preset-env/lib/index.js
- /Users/user/Documents/project/editor/node_modules/#vue/babel-preset-app/index.js
- /Users/user/Documents/project/editor/node_modules/#vue/cli-plugin-babel/preset.js
- /Users/user/Documents/project/editor/node_modules/#babel/core/lib/config/files/plugins.js
- /Users/user/Documents/project/editor/node_modules/#babel/core/lib/config/files/index.js
- /Users/user/Documents/project/editor/node_modules/#babel/core/lib/index.js
- /Users/user/Documents/project/editor/node_modules/#vue/cli-plugin-babel/index.js
- /Users/user/Documents/project/editor/node_modules/#vue/cli-service/lib/Service.js
- /Users/user/Documents/project/editor/node_modules/#vue/cli-service/bin/vue-cli-service.js (While processing: "/Users/user/Documents/project/editor/node_modules/#vue/cli-plugin-babel/preset.js")
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/user/Documents/project/editor/node_modules/#babel/preset-env/lib/polyfills/corejs3/usage-plugin.js:10:55)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/user/Documents/project/editor/node_modules/#babel/preset-env/lib/index.js:29:44)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
# multi (webpack)-dev-server/client?http://192.168.0.105:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
I checked in node_modules/#babel/compat-data/ and the module is there. Why doesn't webpack (is it webpack?) see it?
Note that I did the same thing on another system a few weeks ago and it worked fine.
I also have a vuepress project on the same new system and it also runs fine.
Thanks
In project folder:
rm package_lock.json
rm -r node_modules
npm install
Turns out I had package_lock.json on git from another system. Removed it and it worked.
you can remove the lock files generated (package-lock.json)
and then remove the node modules from your project.
And then again try to download the dependencies via npm
as npm install
Starting a new project, I've installed the latest versions of webpack and webpack-dev-server. I've added the webpack-dev-server command to my start script in my package.json. Oddly, the dev server was working the first time I ran the project, but I then blew away my node_modules folder and reinstalled. Since reinstalling I am continually blocked by the following missing dependency error.
npm start
> webpack-dev-server
module.js:442
throw err;
^
Error: Cannot find module 'hpack.js'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/a6001382/analytics/analytics-q/node_modules/spdy-transport/lib/spdy-transport/protocol/http2/hpack-pool.js:5:13)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
spdy-transport seems to be the culprit, but I am still getting the error even after explicitly running "npm install" on spdy-transports root, and ensuring that "hpack.js" exists.
Has anyone else experienced this missing dependency?
Resolved by running npm i -g npm#latest-4. Some versions of NPM don't correctly set the "main" field of package.json if the package contains a period.
I'm trying to install Gulp js on my computer.
I think it is installed but not completely because when I run gulp -v in powershell it returns these lines:
[12:43:04] CLI version 1.3.0
[12:43:04] Local version 3.9.1
But when I want to run .\node-setup.cmd it throws the following error:
Error: Cannot find module 'gulp-autoprefixer'
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> (C:\LOBOS\FDD.WAP\gulpfile.js:5:20)
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)
Press any key to continue . . .
Any ideas how to solve this?
most likely you have gulp-autoprefixer as a dependency in the package.json file of your project but you did not install it locally.
try to run npm install from the command line and see if it fix your issue.
The problem wouldn't be solved if I would install gulp-autoprefixer because afterwards it would require another module and after that another module and so on...
The solution was to deprecate the package.json file by changing the react-bootstrap-table from my version (2.8.2) to version 4.0.0-beta.2. By doing so, the json file will have a version which is not depending on react-toastr.
Error: Cannot find module 'websocket-server'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (D:\Rahul\hubServer\togetherjs-develop\togetherjs-develop\hub\websocket-compat.js:27:28)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
That means you have not installed that module. To do this do
npm install websocket-server
Usually instead of doing this manually you will have a package.json file and you can install all the modules by doing npm install
I'd you want to save websocket-server to the package run this command:
npm install websocket-server --save
Remember to do npm install __ in the directory of where your site is. Otherwise node won't find it.