Open jccr opened 5 years ago
Tried patching it in my little test project:
{
"name": "rwpm-batch-process",
"version": "1.0.0",
"description": "Process publications to include Readium Web Publication Manifest files.",
"main": "index.js",
"scripts": {
"postinstall": "sed -n '/^#!/p;q' node_modules/.bin/r2-shared-js-cli && sed -i '1s;^;#!/usr/bin/env node\\'$'\n;' node_modules/.bin/r2-shared-js-cli",
"test": "r2-shared-js-cli"
},
"author": "Juan Corona <juanc@evidentpoint.com>",
"license": "MIT",
"dependencies": {
"r2-shared-js": "^1.0.13"
}
}
But I hit another snag:
> rwpm-batch-process@1.0.0 test /home/juanc/Projects/_experiments/rwpm-batch-process
> r2-shared-js-cli
internal/modules/cjs/loader.js:605
throw err;
^
Error: Cannot find module '../models/publication-link'
When the script sourced from node_modules/.bin/r2-shared-js-cli
runs, the require statements
don't seem to map to the paths.
const publication_link_1 = require("../models/publication-link");
Refs:
==>
https://unpkg.com/r2-shared-js@1.0.13/dist/es6-es2015/src/_utils/cli.js
Also note:
Usage instructions:
https://github.com/readium/r2-shared-js/blob/develop/README.md#developer-quick-start
Instead of invoking node_modules/.bin/r2-shared-js-cli
I would call directly: dist/es6-es2015/src/_utils/cli.js
(or even better: dist/es8-es2017/src/_utils/cli.js
).
Error: Cannot find module '../models/publication-link'
Strange! It's definitely there:
https://unpkg.com/r2-shared-js@1.0.13/dist/es8-es2017/src/models/publication-link.js
@danielweck Not sure what was happening... Your comments make sense to me. Ran it again and it worked. :confused:
Found out I got that Error: Cannot find module '../models/publication-link'
because the symlink in node_modules/.bin/r2-shared-js-cli
was broken, and wasn't pointing to the link but a copied regular file. at the time of my testing. (I made this happen, so no actual issue here)
Same issue as https://github.com/readium/r2-streamer-js/issues/44
My use case here is to batch process EPUB publication files from within the NPM package.json scripting mechanism.
Example: