question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pub-sub example: fail to run "Cannot find module"

See original GitHub issue

Error

When running pub-sub example I am getting this error -

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module '../../../proto/dapr/proto/runtime/v1/dapr_pb'
Require stack:
- /Users/yosi/code/dapr-js-sdk/build/implementation/Client/GRPCClient/binding.js
- /Users/yosi/code/dapr-js-sdk/build/implementation/Client/DaprClient.js
- /Users/yosi/code/dapr-js-sdk/build/index.js
- /Users/yosi/code/dapr-js-sdk/examples/pubsub/dist/index.js

Steps to Reproduce the Problem

> git clone  git clone git@github.com:dapr/js-sdk.git dapr-js-sdk
> cd dapr-js-sdk
> npm install
> npm run build
> cd examples/pubsub
> npm install
>  npm run start:dapr-http

Workaround

I changed the dapr-client dependency to come from npm instead of relative file

Environment info:

  • node version: 14.18.1
  • npm version: 6.14.15

Using dapr installed via homebrew -

CLI version: 1.4.0
Runtime version: 1.4.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
XavierGeerinckcommented, Nov 3, 2021

Thanks a lot for your PR! I will close this issue then, if there are any more problems feel free to reopen or ping me

0reactions
yosiatcommented, Nov 3, 2021

Found the issue - https://github.com/dapr/js-sdk/blob/master/scripts/build.sh#L31

We are doing - cp -R ./src/proto/ ./build

In mac, it copies the contents of ./src/proto to build directory, while in linux (tested on popos) it copies the proto folder to build.

js-sdk on  master [!] is 📦 v1.0.2 ❯ ls build
js-sdk on  master is 📦 v1.0.2 ❯ cp -R ./src/proto/ ./build
js-sdk on  master is 📦 v1.0.2 ❯ ls build
dapr  google

As you can see, there is no proto directory, there are dapr & google which are contents of src/proto

If I removed the / (./src/proto/ -> ./src/proto) it works correctly -

js-sdk on  master is 📦 v1.0.2 ❯ rm -rf build/*
zsh: sure you want to delete all 2 files in /Users/yosi/code/dapr/js-sdk/build [yn]? y
js-sdk on  master is 📦 v1.0.2 ❯ cp -R ./src/proto ./build
js-sdk on  master is 📦 v1.0.2 ❯ ls ./build
proto

To test it works correctly, did the change in scripts/build.sh and now the example is working 🎉

Created fix PR - https://github.com/dapr/js-sdk/pull/130

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'google-cloud/pubsub' when deploying app
I've found the source of the error. In the package.json file, I had forgotten to include pubsub as a dependency.
Read more >
Cannot find module 'google-cloud/pubsub' when deploying ...
Coding example for the question Cannot find module 'google-cloud/pubsub' when deploying app-node.js. ... I've found the source of the error.
Read more >
event-pubsub - npm
Super light and fast Extensible ES6+ events and EventEmitters for Node and the browser. Easy for any developer level, use the same exact ......
Read more >
Troubleshoot Dataflow errors | Google Cloud
Cannot read and write in different locations. When you run a Dataflow job, you might see the following error in the log files:....
Read more >
Subscriptions in Apollo Server - Apollo GraphQL Docs
Apollo Server does not provide built-in support for subscriptions. ... For example, a chat application's server might use a subscription to push newly ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found