请慢慢地说清楚并使用简单的单词 - 我以前没有使用node.js,sails.js,ejs或grunt的经验。我来自PHP背景。
我们正在开发一个基于sails.js和ejs的网站。当我们在config / views.js中启用布局时,我们在浏览器控制台中会遇到很多错误。第一个在Firefox中看起来像这样:
ReferenceError: module is not defined
module.exports = function (grunt) {
......在Safari中也是如此:
ReferenceError: Can't find variable: module
global codeGruntfile.js:14
然而,grunt似乎正在起作用,至少部分是:LESS正在编译好,并且布局正在运行。如果我们禁用布局(设置"布局:false"在config / views.js中并重新提升风帆),错误就会消失,但是LESS和布局不会起作用。
我可以解决没有包含布局的问题,但是如果可能的话,我真的很想使用LESS。无论如何,我只是想按照预期的方式使用这个框架。
对不起,这也是我在这里的第一个问题(因为潜伏已经足够多年了),我可能还没有发布足够的技术信息。以下是启用Sails时Safari控制台窗口向我吐出的所有内容(尽管我预计页面上的大部分错误都源于单个配置错误)。如果我能提供更多信息,请告诉我。
谢谢,呃。
[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)
编辑:运行" npm缓存清除"和" npm install"正如评论中所建议的那样:
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
其他编辑2014/09/15:
@KevinKao - 是的,我们在Ubuntu上。我运行aptitude并且警告了以下依赖性问题,并且给了我一个降级nodejs的选项(从0.10.31升级到0.10.25),但是没有降级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
我跑了'aptitude install npm'再一次只是为了好玩,并没有得到任何警告,但当我跑'npm install'我收到了以下警告:
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.
我继续前进并完成了你的程序,但是在开始时我得到了相同的浏览器控制台错误。
答案 0 :(得分:1)
我的同事已将整个文件夹中的内容移至assets / js。我刚把它从资产中移出来,错误就消失了。 Layout.ejs包含此文件夹中的所有内容;因此问题。