Error when trying to run Sails.js app on Trireme

Not applicable

Hi all, I'm running into the following issue when I try to hit the main page of a plain vanilla Sails.js App on Trireme:

Error:

{
  "message": "Cannot call method \"call\" of undefined",
  "fileName": "/usr/local/lib/node_modules/sails/node_modules/glob/glob.js",
  "lineNumber": 310,
  "stack": "TypeError: Cannot call method \"call\" of undefined\n    at /usr/local/lib/node_modules/sails/node_modules/glob/glob.js:310
...}

Main Page

http://localhost:1337/ 

This app was generated by running the command:

sails new sails-plain-vanilla

I've tried to run it on multiple versions of native node: v0.10.32, v0.10.36, v0.10.40, and v0.10.40 and all of them worked with no issues.

This app can be executed either with:

$ sails lift <- works okay. displays "brand new app" on Sails.js

$ node app.js <- works okay. displays "brand new app" on Sails.js

However,

$ trireme app.js <- this one fails with the error above

Am I missing anything?

Thanks!

0 4 203
4 REPLIES 4

Not applicable

I don't know -- I created a Sails app and tried to run it in Trireme and got a totally different error:

Error: ENOENT:/Users/Apigee/src/test/node/sails/test/node_modules/ejs/ejs

It'd be great to figure out what the problem is, but at the moment I'm just not sure.

Thanks for the answer @Greg Brail. I got the same type of errors. So, I followed the content under those folders and in fact, the ejs, grunt, etc. folders don't have the nested ejs. In order to fix it, I regenerated the sails app until instead of creating symlinks, it created real folders. Try either using sails new sails-plain-vanilla --linker or without it. The error posted above happens when all ENOENT errors go away.

Not applicable

I didn't "fix" this but I was able to get the sails app to run under Trireme -- but I had to hack three things.

First of all, the app created using "sails new" contains a bunch of symbolic links in node_modules. Those are fine but there is code in Sails that tries to browse them, and the symbolic links are triggering a Trireme bug https://github.com/apigee/trireme/issues/137

I worked around this in my sails app by removing node_modules inside my app dir and re-installing them with npm:

rm -rf node_modules

npm install

Second, the (old) version of the "glob" package uses one of isaacs's favorite coding patterns, which is to call a function and then declare it in the same scope later on. I have never been able to reproduce this outside his own code, but it is a clever enough coding pattern that it confuses Rhino. That's the error in line 310 of glob.js.

I worked around this by editing my version of "package.json" for the sails package to specify the latest version of "glob," which works around the problem because the code is very different now. Then I ran "npm update" to pick up the new module, and then my app works.

Third, after I added an "api" to my app it wanted to prompt me at the command-line to ask me what to do. Trireme doesn't fully support the "tty" and "readline" modules (because it is for running servers and how often do servers prompt for user input)? However Sails does prompt for user input.

I worked around this last one by editing the file that Sails told me to edit so that it'll stop asking for my input at startup time.

So for a set of fixes:

1) Need to fix the Trireme symlink issue. This is pretty simple.

2) Need to either make Rhino work like V8 (really hard) or update the version of "glob" in this project

3) "tty" and "readline" are surprisingly hard to get right in Trireme. Better to add instructions to edit the file.

Wow! Thank you so much @Greg Brail. This is very helpful workaround. Let me try your steps on my end.

@Ben Tallman - FYI