[英]how to debug SyntaxError: unexpected INDENT error?
i'm working through the peepcode express tutorial, just trying to follow along and get things running, i'm getting the following error when i run npm start, seems like a coffeescript lib problem, i def don't want to get in the weeds with this, any thoughts on where to go? 我正在通过peepcode Express教程进行操作,只是尝试遵循并让事情运行,当我运行npm start时出现以下错误,似乎是一个coffeescript lib问题,我想不想进入带着杂草,对去哪里有什么想法?
[jd@mbp ~/Dropbox/node_projects/tutorials/hot_pie]$ npm start
application-name@0.0.1 start /Users/jd/Dropbox/node_projects/tutorials/hot_pie node server.js
application-name@0.0.1开始/ Users / jd / Dropbox / node_projects / tutorials / hot_pie节点server.js
/Users/jd/Dropbox/node_projects/tutorials/hot_pie/node_modules/coffee-script/lib/coffee- script/helpers.js:199
throw error;
^
SyntaxError: unexpected INDENT
Any thoughts? 有什么想法吗? coffescript is version
"coffee-script": "~1.6.3"
and node is v0.10.13
coffescript是版本
"coffee-script": "~1.6.3"
v0.10.13
"coffee-script": "~1.6.3"
,节点是v0.10.13
For debugging syntax errors I suggest compiling your Coffeescript "manually". 对于调试语法错误,我建议“手动”编译Coffeescript。 I've found that sometimes node's automatic compilation confuses things more than helps.
我发现有时节点的自动编译会使事情变得混乱多于帮助。
So, in your case: 因此,在您的情况下:
$ coffee --compile server.coffee
Now, this will create a server.js file (which you'll want to remove to not confuse node). 现在,这将创建一个server.js文件(您将要删除该文件以免混淆节点)。 If your coffeescript is invalid
coffee
will throw an error. 如果您的coffeescript无效,
coffee
将引发错误。
Edit: 编辑:
To add to this answer, I often syntax check my entire project via the following: I copy all the coffeescript files in my project. 为了增加这个答案,我经常通过以下方式检查我的整个项目的语法:我将所有coffeescript文件复制到我的项目中。 My Coffescript source files live in the
app/
, lib/
, config/
and test/
directories in my project. 我的Coffescript源文件位于我项目的
app/
, lib/
, config/
和test/
目录中。 I've created a temp directory, into which I copy all my coffeescript files then try to compile them all. 我已经创建了一个临时目录,将所有我的coffeescript文件复制到其中,然后尝试将它们全部编译。
$ rm -rf temp/*.coffee
$ rm -rf temp/*.js
$ cp app.coffee temp/
$ find test app lib config test -name "*.coffee" -exec cp \{\} ./temp \;
$ coffee --compile ./temp/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.