使用Riot自定义标签的Browserify出现类型错误问题

5

我正在尝试使用browserify来自定义riot标签。

TypeError: Cannot read property 'render' of null while parsing file: /Users/michaelmostachetti/Google_Drive/dev/web/mike_mostachetti_site/app/views/blog.tag
at _html.jade (/Users/michaelmostachetti/Google_Drive/dev/web/mike_mostachetti_site/node_modules/riot/node_modules/riot-compiler/dist/compiler.js:58:26)
at compileTemplate (/Users/michaelmostachetti/Google_Drive/dev/web/mike_mostachetti_site/node_modules/riot/node_modules/riot-compiler/dist/compiler.js:692:10)
at Object.compile (/Users/michaelmostachetti/Google_Drive/dev/web/mike_mostachetti_site/node_modules/riot/node_modules/riot-compiler/dist/compiler.js:717:11)
at Stream.<anonymous> (/Users/michaelmostachetti/Google_Drive/dev/web/mike_mostachetti_site/node_modules/riotify/index.js:16:58)
at _end (/Users/michaelmostachetti/Google_Drive/dev/web/mike_mostachetti_site/node_modules/riotify/node_modules/through/index.js:65:9)
at Stream.stream.end (/Users/michaelmostachetti/Google_Drive/dev/web/mike_mostachetti_site/node_modules/riotify/node_modules/through/index.js:74:5)
at DestroyableTransform.onend (/Users/michaelmostachetti/npm-global/lib/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:545:10)
at DestroyableTransform.g (events.js:260:16)
at emitNone (events.js:72:20)
at DestroyableTransform.emit (events.js:166:7)

这是我的package.json文件:
"browserify": {
    "transform": [
      [
         "riotify",
         {
              "template": "jade"
         }
      ]
    ]
}

这是我的index.js文件。

var riot        = require('riot'),
    blogView    = require('./views/blog.tag');

riot.mount(blogView);

我对错误和出现的问题感到困惑。我可以将jade编译成html没有任何问题。这是文档中的示例https://github.com/jhthorsen/riotify#usage

1个回答

2
可能是因为没有安装依赖项jade。我刚刚检查了这个错误的堆栈跟踪,它指向了这一行:
return _req('jade').render(html, extend({

所以尝试添加jade,然后再次运行它。


2
实际上,除非您需要预处理HTML(我没有),否则可以摆脱“template”选项。 - Phil Cooper

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接