Skip to content

Implement 'copy' command #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TooTallNate opened this issue Feb 5, 2012 · 5 comments
Closed

Implement 'copy' command #4

TooTallNate opened this issue Feb 5, 2012 · 5 comments

Comments

@TooTallNate
Copy link
Contributor

No description provided.

@cmundi
Copy link

cmundi commented Feb 14, 2012

I'm not sure if this related, but... here is a general question about node-gyp (and maybe bindings) made specific in the context of node-sqlite3.

Now that I have node-sqlite3 building with node-gyp, I would like to be able to relocate it (directly into production and not via uploading an npm package) so that require('sqlite3') just works. I gather this is what 'node-gyp copy' will do when implemented?

I'm not sure why the node requires logic confuses me so much. I've only read the nice docs at nodejs.org a dozen times. I seem to get one thing working and then have trouble with the next. :)

I've been trying to coerce node-bindings into working for any node_modules directory, but I have not been able to get 'bindings' to discover the root, perhaps because I do not have a package.json that it likes and perhaps because I only get about ten minutes to think about this between meetings. The error is something like

Error: Could not find module root given file: C:\Documents and Settings\cm\node_modules\sqlite3\sqlite3.js

where I have put the node_sqlite3.node file right there in the node_modules\sqlite3 folder alongside sqlite3.js.

In the short term, I just need to know how to hack the relocation the the module /lib and *.node artifacts created by node-gyp. I hope this makes sense in a sleep-deprived way.

@TooTallNate
Copy link
Contributor Author

@cmundi The error you are seeing is from node-bindings it indeed is because you do not have a package.json file, so you will need to add one of those to make it find the module root properly. Once you have the package.json in place, then you can see where node-bindings is looking for the native addon module, but for a quick reference:

> require('bindings')('node_sqlite3.node')
Error: Could not load the bindings file. Tried:
 ↳  /Users/nrajlich/node-sqlite3/out/Debug/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/Debug/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/out/Release/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/Release/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/compiled/0.6/darwin/x64/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/build/Release/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/build/default/node_sqlite3.node
    at bindings (/Users/nrajlich/node-sqlite3/node_modules/bindings/bindings.js:78:13)
    at repl:1:20
    at REPLServer.eval (repl.js:80:21)
    at Interface.<anonymous> (repl.js:182:12)

Does that make sense? node-bindings exists because of the historical differences in the location that node's addon files get built by default, so it's designed so that you build the addon and then require 'bindings' and it "just works" (i.e. no copying the resulting binary is necessary).

The copy command would be for the /Users/nrajlich/node-sqlite3/compiled/0.6/darwin/x64/node_sqlite3.node case, where the path is determined at runtime based on the current node version, platform and architecture. You could then commit the resulting copied binary or something, but that's "a sin" and we're still working on a better solution (likely involving npm).

@cmundi
Copy link

cmundi commented Feb 14, 2012

Ah! I was just about to go looking for how to turn on verbose logging for
bindings. Sure enough, a package.json file will get the ball rolling.

Yes, I am very impressed with how node-bindings found the node_sqlite3.node
file in the Release folder. I realized some of what was going on when I
saw that a successful require results in the path to the .node file being
returned as part of the object. So much to learn...

I am very grateful that you and a few other capable devs recognize the
importance of cross-platform support for node. For example, I am working
on an application now which must exist in a heterogeneous networking
environment of Linux and Windows boxes. Node has the potential to make a
lot of things really simple. SO far, I've been doing hackish things just
to get going, but I am looking forward to using your work to create a much
better situation. Thanks!

On Mon, Feb 13, 2012 at 8:42 PM, Nathan Rajlich <
reply@reply.github.com

wrote:

@cmundi The error you are seeing is from node-bindings it indeed is
because you do not have a package.json file, so you will need to add one
of those to make it find the module root properly. Once you have the
package.json in place, then you can see where node-bindings is looking
for the native addon module, but for a quick reference:

> require('bindings')('node_sqlite3.node')
Error: Could not load the bindings file. Tried:
 ↳  /Users/nrajlich/node-sqlite3/out/Debug/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/Debug/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/out/Release/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/Release/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/compiled/0.6/darwin/x64/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/build/Release/node_sqlite3.node
 ↳  /Users/nrajlich/node-sqlite3/build/default/node_sqlite3.node
   at bindings
(/Users/nrajlich/node-sqlite3/node_modules/bindings/bindings.js:78:13)
   at repl:1:20
   at REPLServer.eval (repl.js:80:21)
   at Interface.<anonymous> (repl.js:182:12)

Does that make sense? node-bindings exists because of the historical
differences in the location that node's addon files get built by default,
so it's designed so that you build the addon and then require 'bindings'
and it "just works" (i.e. no copying the resulting binary is necessary).

The copy command would be for the
/Users/nrajlich/node-sqlite3/compiled/0.6/darwin/x64/node_sqlite3.node
case, where the path is determined at runtime based on the current node
version, platform and architecture. You could then commit the resulting
copied binary or something, but that's "a sin" and we're still working on a
better solution (likely involving npm).


Reply to this email directly or view it on GitHub:
#4 (comment)

@cmundi
Copy link

cmundi commented Feb 14, 2012

Got it! I hacked a semi-legit package.json file, found the path which looked nicest (the platform-specific 'compiled' path of course), dropped in node_sqlite3.node and... just like you promised... it just worked. I did all of this in a "deployment" node_modules directory completely separate from where I built node-sqlite3.

Thank You!

@TooTallNate
Copy link
Contributor Author

Closing. I don't think we want/need a copy command after all...

targos pushed a commit to targos/node-gyp that referenced this issue Aug 22, 2021
chore: cleanup unneeded chromium files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants