Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module './lib/reader/rTypes' during schema compilation #5

Closed
sirudog opened this issue Jul 15, 2015 · 7 comments
Closed

Comments

@sirudog
Copy link

sirudog commented Jul 15, 2015

After building the compiler, I try to compile a simple schema with the command:
$ capnp compile -ojs /home/adam/request.capnp

But it gives me this error:
module.js:338
throw err;
^
Error: Cannot find module './lib/reader/rTypes'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/usr/local/lib/node_modules/capnp-js-plugin/index.js:1:80)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
js: plugin failed: exit code 1

It is clear to me that this rTypes module is required in the index.js of the plugin module itself, but I cannot find it anywhere.
It may be relevant that I have an NPM warning during building of the plugin:
npm WARN optional dep failed, continuing fsevents@0.3.6
image

I use Ubuntu 12.04 32-bit. Any help would be appreciated.

@popham
Copy link
Contributor

popham commented Jul 15, 2015

The rTypes.js file is generated by the plugin's build process. The error could indicates a problem with path resolution. I can't remember the last time that I used an absolute path to a schema. Try cd /home/adam/ && capnp compile -ojs request.capnp.

Otherwise, I suspect that this is an environment problem. What is going on with npm install -g .../plugin-master? Are you installing from a repository image or something?

@popham
Copy link
Contributor

popham commented Jul 15, 2015

I've looked at the npm docs, and I see what you're doing. I publish a post-build snapshot of the capnp-js-plugin repository to npm. The github repository doesn't contain some of the files from this snapshot. Try npm uninstall -g capnp-js-plugin && cd /home/adam/Downloads/plugin-master && npm run build && npm install -g .. This will generate the missing files, including rTypes.js, and reinstall globally.

@sirudog
Copy link
Author

sirudog commented Jul 15, 2015

I tried to compile it from /home/adam/, same error.

I downloaded the plugin repo and made a necessary change in the c++ source of the compiler (increased arenaSpace from 20 to 21), because I had the same issue as this: https://groups.google.com/forum/#!topic/capnproto/aeSLSP7b-E0

So I tried to install the plugin from my locally changed source, hence the different install command.

@sirudog
Copy link
Author

sirudog commented Jul 15, 2015

I have just noticed your next comment, that makes sense now, gonna try it now.

@sirudog
Copy link
Author

sirudog commented Jul 15, 2015

So I finally managed to make it work, with a little workaround.
First I did what you suggested, and after installing the gulp dependencies, "npm run build" started but I had these errors in exportreader and exportbuilder tasks, and finally in readers task. Then I gave up.

err

err2

err3

So I did a trick: I started a "normal" install of the plugin from npm repo, and before the build of the c++ compiler failed (due to arenaSpace too low issue), I have copied the lib folder of the plugin (which already contained the extra files you mentioned). Then I pasted this lib folder to my local downloaded plugin repo (which contained the c++ compiler patch for arenaSpace), and install the plugin from my local repo globally. Then the code generation for my schema worked.

If you know what could go wrong in the gulp build step, please let me know. It would be useful in case I bump into it again in the future. For now I have my compiler working so I can move on with my own prototype.

Thanks a lot for looking into this! Cheers

@popham
Copy link
Contributor

popham commented Jul 15, 2015

I blame this mess on my overzealousness. Magically installing the Capnproto compiler is a mistake. Docs should instruct users to install the compiler and refer them to the https://capnproto.org/install.html. A major version update in a week or two will fix this.

@sirudog
Copy link
Author

sirudog commented Aug 29, 2017

I guess I can close this issue after two years has passed without new info about this. There is a new project filling the gap if anyone is trying to use capnproto in js/ts: https://github.com/jdiaz5513/capnp-ts
Hope this helps

@sirudog sirudog closed this as completed Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants