Comments (5)
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.
from node-gyp.
@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).
from node-gyp.
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 <
[email protected]
wrote:
@cmundi The error you are seeing is from
node-bindings
it indeed is
because you do not have apackage.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)
from node-gyp.
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!
from node-gyp.
Closing. I don't think we want/need a copy
command after all...
from node-gyp.
Related Issues (20)
- How to compile static library target in simulator
- Package including other binding.gyp files fails to build on native Windows with "No such file or directory" for binding.sln.gyp.9gyrmwpe.tmp HOT 3
- Compiling on x64 for arm64
- ... .... .- -... ..
- Getting error while installing canvas using npm HOT 6
- Error while installing canvas with npm HOT 1
- Walrus operator only supported in Python 3.8 HOT 1
- Unable to run `node-gyp configure` HOT 1
- node-gyp rebuild command failure HOT 1
- error: failed to commit transaction (conflicting files) HOT 1
- How to enable OpenMP on macOS (clang)
- make error when run without access to `/proc`
- Why is `package-lock.json` ignored?
- Inconsistent Order of build_files in WriteAutoRegenerationRule Causes CI Failures HOT 2
- Could not find any Visual Studio installation to use HOT 1
- node-gyp build fails obscurely if no Xcode or CLT are found
- Can't get node headers HOT 4
- Python >= v3.12 requires node-gyp >= v10 HOT 3
- Error C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1 HOT 2
- The installed files are not consistent
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-gyp.