Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How can I make local changes to node.js library?

How can I make local changes to node.js library?

Problem

I installed some node.js package via npm (specifically, sqlite3). Now I want to add some logging to it's C++ code. I need package to be rebuilt. I tried 'npm edit', but it finishes with errors after 'wq':

npm ERR! weird error 1
npm ERR! not ok code 0

But I don't want use vi or another terminal editor for this. After modifications, I do npm rebuild sqlite3. But it does't rebuild anything! How can I modify packages I have locally?

[sqlite3]: Sweet: "node_sqlite3.node" is valid, node-sqlite3 is now installed!
Problem courtesy of: demi

Solution

sqlite3 module has changed normal build process, npm build will execute 'node build.js'. You can read node_modules/sqlite3/package.json to know how it is built:

  ...
  "scripts": {
    "install": "node build.js",
    "pretest": "node test/support/createdb.js",
    "test": "mocha -R spec --timeout 200000"
  },

If you change your C/C++ code, you can rebuild it using node-gyp

$ cd node_modules/sqlite3
$ node-gyp rebuild

Other option is removing the line "install": "node build.js" from package.json then call npm rebuild again

Solution courtesy of: damphat

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

How can I make local changes to node.js library?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×