Node js error "Error: Cannot find module 'kurento-client'"

655 views
Skip to first unread message

Neil Young

unread,
Jul 21, 2018, 4:42:04 PM7/21/18
to kurento
Too stupid, I'm having literally the same issue as with the React attempt: I cannot load my module.

What I did:

1) The module on KMS is an OpenCV module. Let's call it "kurento-module-myfilter". It is installed there on KMS and loaded. I can talk with it using the browser and a modified "kurento-magic-mirror"
2) I have done what is described here to create a JS client. http://doc-kurento.readthedocs.io/en/stable/user/writing_modules.html. I have taken the resulting "./js" folder and copied it to my client machine into a folder named "kurento-module-myfilter"
3) I have added a dependency to it in package.json:

"dependencies": {
    "cookie-parser": "^1.3.5",
    "express": "~4.12.4",
    "express-session": "~1.10.3",
    "kurento-client": "github:Kurento/kurento-client-js",
    "kurento-module-myfilter": "file://../kurento-module-myfilter",
    "minimist": "^1.1.1",
    "ws": "~1.0.1"
  },

4) I have taken the node js "magic mirror" example, with worked out of the box. I have cross-checked the node "plate-detector" example and found, that there is an extra line in the beginning of "server.js":

kurento.register('kurento-module-platedetector');

5) So I have added the same to my server.js:

kurento.register('kurento-module-myfilter');

6) kurento-module-myfilter is loaded, but it fails on requiring "kurento-client" (I have framed it with two debugger statements. Only the first is hit, then there is an exception (see below))

debugger
var kurentoClient = require('kurento-client');
debugger

7) The exception: 

npm start


> kurento-ma...@6.7.3-dev start /Users/decades/Documents/Node/kurento-tutorial-node/kurento-magic-mirror

> node server.js


module.js:557

    throw err;

    ^


Error: Cannot find module 'kurento-client'

    at Function.Module._resolveFilename (module.js:555:15)

    at Function.Module._load (module.js:482:25)

    at Module.require (module.js:604:17)

    at require (internal/module.js:11:18)

    at Object.<anonymous> (/Users/decades/Documents/Node/kurento-tutorial-node/kurento-module-myfilter/lib/MyFilter.js:21:21)

    at Module._compile (module.js:660:30)

    at Object.Module._extensions..js (module.js:671:10)

    at Module.load (module.js:573:32)

    at tryModuleLoad (module.js:513:12)

    at Function.Module._load (module.js:505:3)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! kurento-ma...@6.7.3-dev start: `node server.js`

npm ERR! Exit status 1

npm ERR! 

npm ERR! Failed at the kurento-ma...@6.7.3-dev start script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


npm ERR! A complete log of this run can be found in:

npm ERR!     /Users/decades/.npm/_logs/2018-07-21T20_28_47_482Z-debug.log

~/Documents/Node/kurento-tutorial-node/kurento-magic-mirror $ 


8) This is stunning, because I had exactly the same issue with the React approach.

Any pointer, what might go wrong here? Or am I making all the time the same mistake?

9) PS: I'm not exactly sure, what the https://github.com/Kurento/kurento-module-creator is good for on the KMS server. I haven't done anything with it up to now. Big mistake?


Neil Young

unread,
Jul 21, 2018, 4:44:38 PM7/21/18
to kurento
PPS: Forgot to say, that this line in server.js works well:

var kurento = require('kurento-client');

Neil Young

unread,
Jul 21, 2018, 10:00:19 PM7/21/18
to kurento
Hehe, in the end it was trivial, as always... But don't ask at what costs... 

Never mind: The big missing thing was the dependency to 'kurento-client-js' in my filter's JS package.json, and I'm not sure (and too tired) to think about, if to enter this wouldn't have been a task for the scaffolder. Maybe it is described somewhere, I don't know...

So instead of

"dependencies": {
    "es6-promise": "^2.0.1",
    "inherits": "^2.0.1",
    "promisecallback": "^0.0.3"
  },

this:

"dependencies": {
    "es6-promise": "^2.0.1",
    "inherits": "^2.0.1",
    "kurento-client": "github:Kurento/kurento-client-js",
    "promisecallback": "^0.0.3"
  },

At least I didn't have to bite that hard for a long time. I have total respect for your work, guys. Thumbs up!

Now the way is clear and just needs to be gone.

Thanks and HTH

Micael Gallego

unread,
Jul 22, 2018, 6:10:50 AM7/22/18
to kur...@googlegroups.com
Pull Requests in documentation are welcomed ;)

--
You received this message because you are subscribed to the Google Groups "kurento" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kurento+u...@googlegroups.com.
To post to this group, send email to kur...@googlegroups.com.
Visit this group at https://groups.google.com/group/kurento.
To view this discussion on the web visit https://groups.google.com/d/msgid/kurento/8ceedd71-96d7-4ba7-ae37-badfc182adcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neil Young

unread,
Jul 22, 2018, 6:11:46 AM7/22/18
to kur...@googlegroups.com
Could we meet in chatroom if you have some minutes?

Reply all
Reply to author
Forward
0 new messages