Closed alexeckermann closed 7 years ago
Upon further research into this, I looks as though the purpose of index.js
was changed upstream in node-canvas during 2.0.0 commits.
In that case I'll put a pull request together as I now believe this will be necessary going forward.
Yeah, you're right. It looks like it's been wrong since 2.0.0-alpha.3
😞 Thanks for reporting though!
Fixed via #22
Looks like the changed path does not affect to the module as there is no new release since this changes.
Maybe this patch would be helpful until get the new release of the module?
const {join} = require('path');
const readPkg = require('read-pkg');
const writePkg = require('write-pkg');
const packagePath = join('node_modules', 'canvas-prebuilt');
(async () => {
const packageJSON = await readPkg(packagePath);
await writePkg(packagePath, {
...packageJSON,
main: './canvas/index.js',
});
})();
"postinstall": "node scripts/_patch-canvas-prebuilt.js"
https://github.com/node-gfx/node-canvas-prebuilt/blob/25087a490e93462492f648bfcbca6521a9029315/package.json#L28
Using the latest
2.0.0-alpha.5
, themain
is pointing to./canvas/lib/canvas.js
which doesn't make any of what is described in./canvas/index.js
available — such asregisterFont
andImage
.I'm not a day-to-day node user so I am interested to know if this is intentional? In basic debugging locally, changing the reference of main to point to the index file I got access to everything I was expecting to.