balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

Error: Cannot find module 'send(html); }' #1674

Closed ChristianGaertner closed 10 years ago

ChristianGaertner commented 10 years ago

I' ve just done a clean install of the sails v0.10.0-rc6. I've run these (and only these commands): npm install -g sails@beta' sails new test sails lift`

Works great! Then I generated my first model: sails generate api user

and started the server again

sails lift

The homepage at localhost:1337 still works. But when I navigate to the newly created resource (/user) I get the following error:

error: Sent 500 ("Server Error") response
error: Error: Cannot find module 'send(html);
  }'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at View (/usr/local/lib/node_modules/sails/node_modules/express/lib/view.js:43:49)
    at new SailsView (/usr/local/lib/node_modules/sails/lib/hooks/http/view.js:32:15)
    at Function.app.render (/usr/local/lib/node_modules/sails/node_modules/express/lib/application.js:486:12)
    at ServerResponse.res.render (/usr/local/lib/node_modules/sails/node_modules/express/lib/response.js:801:7)
    at ServerResponse._addResViewMethod.res.view (/usr/local/lib/node_modules/sails/lib/hooks/views/res.view.js:174:16)
    at Object.sendOK (/Users/Christian/tmp/test/api/responses/ok.js:71:19) Error: Cannot find module 'send(html);
  }'

I think it is quite annoying when a clean and fresh install just errors... Or did I something wrong? (This problem is reproducible every time!)

Cheers, Christian

sgress454 commented 10 years ago

What's in your api/responses/ok.js? Looks like that's where the error is coming from...

ChristianGaertner commented 10 years ago

This is the exact copy of cat ok.js (using cat ok.js | pbcopy): (I haven't modified this file in any way!)

/**
 * 200 (OK) Response
 *
 * Usage:
 * return res.ok();
 * return res.ok(data);
 * return res.ok(data, view);
 * return res.ok(data, redirectTo);
 * return res.ok(data, true);
 *
 * @param  {Object} data
 * @param  {Boolean|String} viewOrRedirect
 *         [optional]
 *          - pass string to render specified view
 *          - pass string with leading slash or http:// or https:// to do redirect
 */

module.exports = function sendOK (data, viewOrRedirect) {

    // Get access to `req` & `res`
  var req = this.req;
  var res = this.res;

  // Serve JSON (with optional JSONP support)
  function sendJSON (data) {
    if (!data) {
      return res.send();
    }
    else {
      if (typeof data !== 'object') { return res.send(data); }
      if ( req.options.jsonp && !req.isSocket ) {
        return res.jsonp(data);
      }
      else return res.json(data);
    }
  }

  // Set status code
  res.status(200);

  // Log error to console
  this.req._sails.log.verbose('Sent 200 ("OK") response');
  if (data) {
    this.req._sails.log.verbose(data);
  }

    // Serve JSON (with optional JSONP support)
    if (req.wantsJSON) {
        return sendJSON(data);
    }

  // Make data more readable for view locals
  var locals;
  if (!data || typeof data !== 'object'){
    locals = {};
  }
  else {
    locals = data;
  }

  // Serve HTML view or redirect to specified URL
  if (typeof viewOrRedirect === 'string') {
    if (viewOrRedirect.match(/^(\/|http:\/\/|https:\/\/)/)) {
      return res.redirect(viewOrRedirect);
    }
    else return res.view(viewOrRedirect, locals, function viewReady(viewErr, html) {
      if (viewErr) return sendJSON(data);
      else return res.send(html);
    });
  }
  else return res.view(locals, function viewReady(viewErr, html) {
    if (viewErr) return sendJSON(data);
    else return res.send(html);
  });

};
sgress454 commented 10 years ago

Sorry, we're pushing rc7 today to fix a couple of issues that sneaked into Tuesday's release. If you pull the master branch of Sails (or do npm install -g sails@git://github.com/balderdashy/sails.git) the issue should be resolved.

ChristianGaertner commented 10 years ago

Okey great. Is there any ETA for 0.10 so far? (Couldn't find any...)

sgress454 commented 10 years ago

Balderdash has had a lot of client work lately, which is nice (it keeps the lights on), but it has delayed the finishing touches on v0.10 somewhat. Release hiccups aside, we're mainly just polishing up documentation at this point. We really hope to have it out this month.

ChristianGaertner commented 10 years ago

Sounds awesome!