Grunt 403禁止错误

时间:2014-01-03 22:37:53

标签: node.js gruntjs

我正在使用node和grunt来处理我从github克隆的现有JS项目。

npm install
grunt

Grunt将我的浏览器启动到localhost:8000并打开索引页。

索引页面加载,但是当浏览器尝试获取资产时,我收到所有403错误

Error: Forbidden
at SendStream.error (/Users/dylanjhaveri/code/skeuocard/node_modules/grunt-express/node_modules/connect/node_modules/send/lib/send.js:145:16)
at SendStream.pipe (/Users/dylanjhaveri/code/skeuocard/node_modules/grunt-express/node_modules/connect/node_modules/send/lib/send.js:310:52)
at Object.static (/Users/dylanjhaveri/code/skeuocard/node_modules/grunt-express/node_modules/connect/lib/middleware/static.js:84:8)
at next (/Users/dylanjhaveri/code/skeuocard/node_modules/grunt-express/node_modules/connect/lib/proto.js:190:15)
at Function.app.handle (/Users/dylanjhaveri/code/skeuocard/node_modules/grunt-express/node_modules/connect/lib/proto.js:198:3)
at Server.app (/Users/dylanjhaveri/code/skeuocard/node_modules/grunt-express/node_modules/connect/lib/connect.js:65:37)
at Server.EventEmitter.emit (events.js:98:17)
at HTTPParser.parser.onIncoming (http.js:2108:12)
at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
at Socket.socket.ondata (http.js:1966:22)

1 个答案:

答案 0 :(得分:8)

修复是这样的:在Gruntfile.coffee:

改变这个:

express:
  all:
    options:
      port: 8000
      hostname: "0.0.0.0"
      bases: ['.']

到此:

express:
  all:
    options:
      port: 8000
      hostname: "0.0.0.0"
      bases: [__dirname]