node-clr icon indicating copy to clipboard operation
node-clr copied to clipboard

Build using node-pre-gyp

Open jochemstoel opened this issue 7 years ago • 1 comments

I'm almost there. I can build clr with node-pre-gyp and it creates a clr.node file. However when I require it, it has no init() method. In stead it looks like this:

{ import: [Function],
  getAssemblies: [Function],
  getTypes: [Function],
  createConstructor: [Function],
  getMembers: [Function],
  invokeMethod: [Function],
  getField: [Function],
  setField: [Function],
  isCLRObject: [Function],
  getType: [Function],
  isCLRConstructor: [Function],
  typeOf: [Function],
  path: 'C:\\Users\\Administrator\\Desktop\\build\\Release\\clr.node' }

I am using the following package.json to build it:

{
  "name": "clr",
  "version": "0.0.18",
  "engines": {
    "node": ">=0.12 <8"
  },
  "description": "Node.js binding for .NET Framework API",
  "repository": {
    "type": "git",
    "url": "https://github.com/AtsushiSuzuki/node-clr"
  },
  "main": "lib/clr.js",
  "scripts": {
    "test": "mocha"
  },
  "dependencies": {
    "bindings": "^1.2.1",
    "nan": "^2.4.0",
    "node-pre-gyp": "^0.6.38",
    "underscore": "^1.8.3"
  },
  "devDependencies": {
    "mocha": "*",
    "aws-sdk": "2.x"
  },
  "bundledDependencies":["node-pre-gyp"],
    "scripts": {
        "install": "node-pre-gyp install --fallback-to-build"
    },
    "binary": {
        "module_name": "clr",
        "module_path": "./lib/",
        "host": "https://clr.s3-us-west-1.amazonaws.com"
    },
  "keywords": [
    ".NET",
    "CLR",
    "Common Language Runtime",
    "API Bridge"
  ],
  "author": {
    "name": "Atsushi Suzuki",
    "email": "[email protected]"
  },
  "license": "(ISC OR WTFPL)",
  "gypfile": true
}

And I then simply do:

var clr = require('clr') // or require('bindings')('clr.node'), no difference

What am I missing, Atsushi?

jochemstoel avatar Sep 30 '17 13:09 jochemstoel

Great!

node-clr has lib/clr.js as main script. lib/clr.js utilizes clr.node. If you do require(".") or require("lib/clr.js"), it will have documented APIs.

AtsushiSuzuki avatar Sep 30 '17 23:09 AtsushiSuzuki