demi
demi

Reputation: 5504

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

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!

Upvotes: 2

Views: 1555

Answers (1)

damphat
damphat

Reputation: 18956

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

Upvotes: 4

Related Questions