Error: Cannot find module 'google-protobuf' - javascript

Following to my previous question, I'm trying to use protocol buffers in node.js. I've generated ServiceMessage_pb.js from my ServiceMessage.proto, and add the following code:
var messages = require('./ServiceMessage_pb');
Now I'm getting the following error in my node log:
Error: Cannot find module 'google-protobuf'
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> (/home/aii/ws/ServiceMessage_pb.js:8:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
Any suggestions how to solve this?
Thanks

npm i google-protobuf
I run into so many problem installing just "protobuf" !
Also the official protobuf javascript package is "google-protobuf":
https://www.npmjs.com/package/google-protobuf

You can install the module with npm:
npm install --save protobuf
Then require it this way:
var my_protobuff = require ("protobuf");

Related

Struggling with running Storybook

Hi I'm a beginner learning React & I'm trying out Storybook and I am having the following error when I try to run Storybook. **I tried to update by using npm update, I thought there was conflict with my dependencies **
ERROR in ./.storybook/generated-refs.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: You gave us a visitor for the node type StaticBlock but it's not a valid type
at verify (C:\Users\msngw\OneDrive\Desktop\SBook\myapp\node_modules\#babel\traverse\lib\visitors.js:112:13)
at explode (C:\Users\msngw\OneDrive\Desktop\SBook\myapp\node_modules\#babel\traverse\lib\visitors.js:34:3)
at Object.merge (C:\Users\msngw\OneDrive\Desktop\SBook\myapp\node_modules\#babel\traverse\lib\visitors.js:147:5)
at Object.<anonymous> (C:\Users\msngw\OneDrive\Desktop\SBook\myapp\node_modules\#babel\helper-replace-supers\lib\index.js:60:44)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Users\msngw\OneDrive\Desktop\SBook\myapp\node_modules\#babel\helper-create-class-features-plugin\lib\fields.js:13:52)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:903:19)
# multi ./node_modules/#storybook/core/dist/server/common/polyfills.js ./node_modules/#storybook/core/dist/client/manager/index.js ./node_modules/#storybook/addon-links/dist/register.js ./node_modules/#storybook/addon-actions/dist/register.js ./node_modules/#storybook/addon-docs/dist/register.js ./node_modules/#storybook/addon-controls/dist/register.js ./node_modules/#storybook/addon-backgrounds/dist/register.js ./node_modules/#storybook/addon-viewport/dist/register.js ./node_modules/#storybook/addon-toolbars/dist/register.js ./.storybook/generated-refs.js main[9]
This bug has been already raised in the Storybook repo. As mentioned there, removing yarn.lock and node_modules, then re-installing using yarn, fixed all issues.

Svelte/Sapper - Running __sapper__/build cannot find module

I don't get any errors in dev or in the process of actually building via npm run build, but upon trying to run node __sapper__/build on my linux VM I get a Cannot find module error
/opt/bitnami/apps/bookbot/htdocs$ node __sapper__/build
Starting server on port 3000
internal/modules/cjs/loader.js:628
throw err;
^Error: Cannot find module 'lodash/groupby'
Require stack:
- /opt/bitnami/apps/bookbot/htdocs/__sapper__/build/server/bookings-b0b7de1b.js
- /opt/bitnami/apps/bookbot/htdocs/__sapper__/build/server/server.js
- /opt/bitnami/apps/bookbot/htdocs/__sapper__/build/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
at Function.Module._load (internal/modules/cjs/loader.js:527:27)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/opt/bitnami/apps/bookbot/htdocs/__sapper__/build/server/bookings-b0b7de1b.js:10:1)
at Module._compile (internal/modules/cjs/loader.js:777:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/opt/bitnami/apps/bookbot/htdocs/__sapper__/build/server/bookings-b0b7de1b.js',
'/opt/bitnami/apps/bookbot/htdocs/__sapper__/build/server/server.js',
'/opt/bitnami/apps/bookbot/htdocs/__sapper__/build/index.js'
]}
I've tried npm i lodash --save, makes no difference. Not sure where I'm going wrong?
Shouldn't it be lodash/groupBy with an uppercase 'B'? How do you make that pass in dev?

How to fix 'Error: Cannot find module '/lib/index' on Node JS

I'm adding 1 new library to my project (express-fileupload), but, when run node server this return that message, I tried with the commands:
npm install
npm loader
npm install winston (this for a problem reported in a Github project)
npm start
but this dont work.
$ node server.js
internal/modules/cjs/loader.js:605
throw err;
^
Error: Cannot find module '/lib/index'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\david\Documents\INTRANET\dusoft-server\server.js:15:18)
at Module._compile (internal/modules/cjs/loader.js:721:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)

Error: Cannot find module 'update-notifier'. I cannot install any NPM

There is a similar question on StackOverFlow but it was unhelpful and it wasn't answered. I have been working on a project and I currently am receiving this error.
Error: Cannot find module 'update-notifier'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:29:19
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
If I type any command that includes npm it returns the same error, I can't install anything.
I have tried to uninstall/re-install NodeJS with homebrew but nothing changed from trying that.

Module Not Found Node Js 'to-fast-properties'

I have updated my node to latest one.
I have also tried uninstalled and reinstalled the node one time to fix this problem but no success.
I have also run the command sudo npm install -g to-fast-properties to install this module.
Can anyone help why this error is still coming?
browserify -t babelify app.js -o bundle.js
module.js:338
throw err;
^
Error: Cannot find module 'to-fast-properties'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/saurabhchaudhary/www/react-soundplayer/examples/node_modules/babelify/node_modules/babel-core/lib/types/index.js:23:25)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
By the I am using react library which I would like to browserify my js code to execute in browser. Is there any other way to do same?

Categories