Weird Node js error

微信扫一扫,分享到朋友圈

Weird Node js error

I am not much familiar with node js, but I was forced to use node js to launch on heroku.

It all went smoothly, probably until a few days ago, but I didn’t know why but it suddenly gives this much error.

Error: /app/index.jade:9
7| meta(name='viewport', content='target-densitydpi=device-dpi, width=device-width, user-scalable=no, maximum-scale=1, minimum-scale=1')
8| link(rel='stylesheet', href='https://www.tuicool.com/stylesheets/bootstrap.min.css', media='screen')
> 9| link(rel='stylesheet', href='https://www.tuicool.com/articles/iiuIzye/stylesheets/jquery-ui.css', media='screen')
10| link(rel='stylesheet', href='https://www.tuicool.com/articles/iiuIzye/stylesheets/jquery.pnotify.default.css', media='screen')
11| link(rel='stylesheet', href='https://www.tuicool.com/articles/iiuIzye/stylesheets/jquery.pnotify.default.icons.css', media='screen')
12| link(rel='stylesheet', href='https://www.tuicool.com/articles/iiuIzye/stylesheets/app.css', media='screen')
unexpected text at Object.Lexer.fail (/app/node_modules/jade/lib/lexer.js:804:11)
at Object.Lexer.next (/app/node_modules/jade/lib/lexer.js:863:15)
at Object.Lexer.lookahead (/app/node_modules/jade/lib/lexer.js:113:46)
at Parser.lookahead (/app/node_modules/jade/lib/parser.js:111:23)
at Parser.peek (/app/node_modules/jade/lib/parser.js:88:17)
at Parser.tag (/app/node_modules/jade/lib/parser.js:704:22)
at Parser.parseTag (/app/node_modules/jade/lib/parser.js:690:17)
at Parser.parseExpr (/app/node_modules/jade/lib/parser.js:199:21)
at Parser.block (/app/node_modules/jade/lib/parser.js:660:25)
at Parser.tag (/app/node_modules/jade/lib/parser.js:777:26)

This is What my index.jade is about

doctype html
html(lang="en")
head
meta(name='apple-mobile-web-app-capable', content='yes')
meta(name='apple-mobile-web-app-status-bar-style', content='black')
meta(name='viewport', content='target-densitydpi=device-dpi, width=device-width, user-scalable=no, maximum-scale=1, minimum-scale=1')
link(rel='stylesheet', href='https://www.tuicool.com/stylesheets/bootstrap.min.css', media='screen')
link(rel='stylesheet', href='https://www.tuicool.com/articles/iiuIzye/stylesheets/jquery-ui.css', media='screen')
link(rel='stylesheet', href='https://www.tuicool.com/articles/iiuIzye/stylesheets/jquery.pnotify.default.css', media='screen')
link(rel='stylesheet', href='https://www.tuicool.com/articles/iiuIzye/stylesheets/jquery.pnotify.default.icons.css', media='screen')

Any suggestion why it becomes wrong?

Problem courtesy of: AlfredTK

Solution

Try changing your Jade to

doctype html
html(lang="en")
head
meta(name='apple-mobile-web-app-capable', content='yes')
meta(name='apple-mobile-web-app-status-bar-style', content='black')
meta(name='viewport', content='target-densitydpi=device-dpi, width=device-width, user-scalable=no, maximum-scale=1, minimum-scale=1')
link(rel='stylesheet', href='https://www.tuicool.com/stylesheets/bootstrap.min.css', media='screen')
link(rel='stylesheet', href='https://www.tuicool.com/stylesheets/jquery-ui.css', media='screen')
link(rel='stylesheet', href='https://www.tuicool.com/stylesheets/jquery.pnotify.default.css', media='screen')
link(rel='stylesheet', href='https://www.tuicool.com/stylesheets/jquery.pnotify.default.icons.css', media='screen')

As @Max Leske said in the comments, you are mixing relative and absolute paths.

Not sure why that would be causing an issue, but it’s more than a coincidence I feel.

Incidently, the reason I asked to see your package.json
is because recently there was an update to Jade on NPM that has caused the issue you are reporting:

https://github.com/visionmedia/jade/issues/1347

If you have something like:

"jade" : "*"

in your package.json
that will basically mean “install the latest version”

So, every time you push to heroku, it will update your version of jade to the latest version, thus introducing any breaking changes.

I suspect this is what happened a few days ago, causing this bug (you pushed to heroku, forcing an update of jade to the latest version)

It would be better to specify version numbers in your package.json
file to avoid this.

Solution courtesy of: Alex

一个支持 CodeFirst/DbFirst/ModelFirst 的数据库小工具

上一篇

【万字长文】Spring框架 层层递进轻松入门 (IOC和DI)

下一篇

你也可能喜欢

Weird Node js error

长按储存图像,分享给朋友