0

I am trying to install node-opencv . The repo is successfully build . I want the opencv project to be installed as node_module globally .

Is that possible ?

I am new to node world.


'node-gyp rebuild' is same as 'npm install' ?

Because is built the repo of node-opencv but still my project looks for the dependency for HTTP

Answered : by Jonathan Lonowski in his comment.Please read the comments .Really helpful


I have opencv as dependency in my project .I have build the repo of opencv But still my project is making http call for opencv dependency.

I want the build repo to be used .

saurabh shashank
  • 1,343
  • 2
  • 14
  • 22

1 Answers1

2

I want the opencv project to be installed as node_module globally. Is that possible?

"Global" packages, installed with -g or --global option, are not intended to be available for require():

  • Install it locally if you're going to require() it.
  • Install it globally if you're going to run it on the command line.

You can, however, install them locally to a parent directory. As long as the location can be found following the rules described for node_module folders, it can be required:

For example, if the file at '/home/ry/projects/foo.js' called require('bar.js'), then node would look in the following locations, in this order:

  • /home/ry/projects/node_modules/bar.js
  • /home/ry/node_modules/bar.js
  • /home/node_modules/bar.js
  • /node_modules/bar.js

I have build the repo of opencv But still my project is making http call for opencv dependency.

For this, it would help if you could elaborate on how you've installed the package, including how you're specifying it as a dependency.

But, further HTTP requests should only be needed for packages upon request:

# download and build the latest version
npm install opencv

# it should remain at that version until you request an update
npm update opencv
Community
  • 1
  • 1
Jonathan Lonowski
  • 121,453
  • 34
  • 200
  • 199
  • The node-opencv project has used binding.gyp . Installation link says to build repo ."node-gyp rebuild " is same as "npm install" ? – saurabh shashank Apr 23 '13 at 14:36
  • 1
    @saurabhshashank `npm install` will use [`node-gyp rebuild`](https://github.com/peterbraden/node-opencv/blob/master/package.json#L14) to finish installing. Typically, you install from repo when your intention is to work on the project itself. Use `npm install` when you want it as a dependency. You can alternatively specify a [dependency by Git URL](https://npmjs.org/doc/json.html#Git-URLs-as-Dependencies) or use [`npm link`](https://npmjs.org/doc/link.html) after building the repo. – Jonathan Lonowski Apr 23 '13 at 14:38
  • thanks a lot . I am able to build the repo , but npm install is not working for same project . – saurabh shashank Apr 23 '13 at 14:41
  • 1
    @saurabhshashank Amend: They're not the same; but `node-gyp rebuild` will be called either way (directly by you in the repo or by `npm install` within copy it downloads). Also, "*not working*" how? Do you get an error from the command? – Jonathan Lonowski Apr 23 '13 at 14:48
  • yup while creating make file : CXX(target) Release/obj.target/opencv/src/init.o In file included from ../src/init.cc:4:0: ../src/CascadeClassifierWrap.h:16:35: error: ‘eio_req’ has not been declared ../src/CascadeClassifierWrap.h:17:39: error: ‘eio_req’ has not been declared make: *** [Release/obj.target/opencv/src/init.o] Error – saurabh shashank Apr 23 '13 at 14:49
  • 1
    @saurabhshashank There's an issue on the project that reports a similar (if not same) error: https://github.com/peterbraden/node-opencv/issues/41. Seems that it's a compatibility issue between the current release and Node v0.10. – Jonathan Lonowski Apr 23 '13 at 14:55
  • Thanks a lot . I will try it with node0.8 and update the qus . – saurabh shashank Apr 23 '13 at 14:57
  • Take a look at nvm (node version manager) https://github.com/creationix/nvm. nvm makes working with multiple versions of node.js much easier – Noah Apr 23 '13 at 15:05