Please speak slowly and clearly and use simple words-- I have no previous experience with node.js, sails.js, ejs, or grunt. I come from a PHP background.
We are developing a website based on sails.js and ejs. When we enable layouts in config/views.js, we get a lot of errors in the browser console. The first looks like this in Firefox:
ReferenceError: module is not defined
module.exports = function (grunt) {
...and like this in Safari:
ReferenceError: Can't find variable: module
global codeGruntfile.js:14
However, grunt seems to be working, at least in part: LESS are compiling OK, and the layouts are working. If we disable layouts (set "layout:false" in config/views.js and re-lift sails), the errors disappear, but then LESS and the layouts don't work.
I can work around not having the layouts with includes, but I'd really like to use LESS if at all possible. Anyways, I'd just like to use this framework the way it was intended to be used.
Sorry, it's also my first question here (as lurking has been enough for years), and I probably haven't posted enough technical information. Here is everything that the Safari console window spits at me when Sails is enabled (though I expect most of the errors down the page stem from a single config error). Let me know if I can provide any more information.
Thanks, eh.
[Error] ReferenceError: Can't find variable: module (Gruntfile.js, line 14)
[Error] ReferenceError: Can't find variable: angular
(anonymous function) (app.js, line 21)
[Error] TypeError: 'undefined' is not an object (evaluating '$.ajaxSetup') (jquery.postmessage-transport.js, line 50)
[Error] ReferenceError: Can't find variable: angular (jquery.fileupload-angular.js, line 33)
[Error] TypeError: 'undefined' is not an object (evaluating '$.blueimp') (jquery.fileupload-audio.js, line 35)
[Error] TypeError: 'undefined' is not an object (evaluating '$.blueimp')
(anonymous function) (jquery.fileupload-image.js, line 39)
(anonymous function) (jquery.fileupload-image.js, line 30)
[Error] TypeError: 'undefined' is not an object (evaluating '$.widget') (jquery.fileupload-jquery-ui.js, line 27)
[Error] TypeError: 'undefined' is not an object (evaluating '$.blueimp') (jquery.fileupload-process.js, line 32)
[Error] TypeError: 'undefined' is not an object (evaluating '$.blueimp') (jquery.fileupload-ui.js, line 37)
[Error] TypeError: 'undefined' is not an object (evaluating '$.blueimp') (jquery.fileupload-validate.js, line 32)
[Error] TypeError: 'undefined' is not an object (evaluating '$.blueimp') (jquery.fileupload-video.js, line 35)
[Error] TypeError: 'undefined' is not an object (evaluating '$.support') (jquery.fileupload.js, line 32)
[Error] TypeError: 'undefined' is not an object (evaluating '$.ajaxTransport')
(anonymous function) (jquery.iframe-transport.js, line 39)
(anonymous function) (jquery.iframe-transport.js, line 21)
[Error] ReferenceError: Can't find variable: $ (main.js, line 14)
[Error] ReferenceError: Can't find variable: jQuery (jquery.ui.widget.js, line 18)
[Error] SyntaxError: Invalid character: '#' (server.js, line 1)
[Error] ReferenceError: Can't find variable: $ (test.js, line 14)
[Error] ReferenceError: Can't find variable: jwplayer (jwplayer.html5.js, line 1)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (jquery-1.10.2.min.map, line 0)
[Log]
|>
\___/
[Log] `io.socket` connected successfully.
(for help, see: http://sailsjs.org/#!documentation/reference/BrowserSDK/BrowserSDK.html)
edit: running "npm cache clear" and "npm install" as suggested in the comments resulted in this:
npm WARN package.json crypto@0.0.3 crypto is also the name of a node core module.
npm WARN unmet dependency /home/ubuntu/git/(obscured)/frontend/node_modules/sails-disk/node_modules/waterline-criteria requires lodash@'~2.4.1' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /home/ubuntu/git/(obscured)/frontend/node_modules/sails-disk/node_modules/waterline-cursor requires lodash@'~2.4.1' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
additional edit 2014/09/15:
@KevinKao - Yes, we're on Ubuntu. I ran aptitude and it warned of the following dependency issues, and gave me an option to downgrade nodejs (from 0.10.31 to 0.10.25), but no option to downgrade npm.
The following packages have unmet dependencies:
nodejs : Conflicts: npm but 1.3.10~dfsg-1 is to be installed.
The following actions will resolve these dependencies:
Install the following packages:
1) nodejs-dev [0.10.25~dfsg2-2ubuntu1 (trusty)]
Downgrade the following packages:
2) nodejs [0.10.31-1chl1~trusty1 (now, trusty) -> 0.10.25~dfsg2-2ubuntu1 (tr //oops truncated it
I ran 'aptitude install npm' again just for fun and didn't get any warnings, but when I ran 'npm install' I got the following warnings:
npm WARN deprecated grunt-lib-contrib@0.7.1: DEPRECATED. See readme: https://github.com/gruntjs/grunt-lib-contrib
npm WARN deprecated guid@0.0.12: Please use node-uuid instead. It is much better.
I went ahead and finished your procedure anyways, but got the same browser console errors that I was getting at the outset.