错误:找不到模块'jade~'

时间:2013-03-08 08:22:44

标签: javascript node.js pug railway.js compoundjs

我是节点js的新手。我使用Compound Js来创建一个crud操作。

应用程序工作正常,直到我尝试提醒值,之后我收到错误

500 Error: Cannot find module 'jade~'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)

如何解决此问题

我的索引

#tabs
  ul
    li
      a(href='#tabs-1') New Leave
    li
      a(href='#tabs-2') Index of Leave
  #tabs-1
    .page-header
      h1 New employee

    - var form = formFor(employee, {action: pathTo.employees(), method: 'POST', id: "employee_form", class: 'form-horizontal'})

    != form.begin()
    != errorMessagesFor(employee) 
    .control-group
      != form.label("code", false, {class: "control-label"})
      .controls
        != form.input("code")
    .control-group
     != form.label("description", false, {class: "control-label"})
      .controls
        != form.input("description")
    .control-group
      != form.label("applicable", false, {class: "control-label"})
      .controls
        != form.input("applicable")
    .control-group
      != form.label("cForward", false, {class: "control-label"})
      .controls
        != form.checkbox("cForward")
    .control-group
      != form.label("limit", false, {class: "control-label"})
      .controls
        != form.checkbox("limit")
    .control-group
      != form.label("lop", false, {class: "control-label"})
      .controls
        != form.checkbox("lop")
    .control-group
      != form.label("od", false, {class: "control-label"})
      .controls
        != form.checkbox("od")
    .control-group
      != form.label("co", false, {class: "control-label"})
      .controls
        != form.checkbox("co")
    .control-group
      != form.label("lrevision", false, {class: "control-label"})
      .controls
        != form.checkbox("lrevision")
    .control-group
      != form.label("active", false, {class: "control-label"})
      .controls
        != form.checkbox("active")
    .form-actions
      != form.submit('<i class="icon-ok icon-white"></i>  Create employee', {class: 'btn btn-primary'})
      span= ' or '
      != linkTo('Cancel', pathTo.employees(), {class: 'btn'})
    != form.end()
  #tabs-2
    .page-header
      h1 Index of employees


    .row
      .span12
         p
            != linkTo('<i class="icon-plus icon-white"></i> New employee', path_to.new_employee(), {class: 'btn btn-primary'})

    - if (employees.length) {
    .row
      .span12
         table.table.table-striped
           thead
             tr
               th ID
               th.span3 Actions
           tbody
             - employees.forEach(function (employee) {
             tr
               td
                 != linkTo('employee #' + employee.id, path_to.employee(employee))
               td
                 != linkTo('<i class="icon-edit"></i> Edit', pathTo.edit_employee(employee), {class: 'btn btn-mini'}) + ' '
                 != linkTo('<i class="icon-remove icon-white"></i> Delete', pathTo.employee(employee), {class: 'btn btn-mini btn-danger', method: 'delete', remote: true, jsonp: '(function (u) {location.href = u;})'})
             - });
    - } else{
    .row
      .span12
         p.alert.alert-block.alert-info
            strong No employees were found.
    - } 

布局文件

!!! 5
html
  head
    title= title
    != stylesheetLinkTag('http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/base/jquery-ui.css', 'bootstrap', 'application', 'bootstrap-responsive')
    != javascriptIncludeTag('https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.js', 'rails', 'application')
    script
      $(document).ready(function() {
        $("#tabs").tabs();
      });
    != csrfMetaTag()
  body
    .navbar
        .navbar-inner
            .container
               a.brand(href='#') Project name

    .container
      - var flash = request.flash('info').pop(); if (flash) {
        .alert.alert-info= flash
      - }

      - flash = request.flash('error').pop(); if (flash) {
        .alert.alert-error= flash
      - }

      != body

      hr
      footer
        p © Company 2012
  != contentFor('javascripts')

7 个答案:

答案 0 :(得分:22)

我在nodeschool expressworks教程中遇到了同样的问题。我通过在package.json中包含依赖项来解决它:

npm install --save express jade

答案 1 :(得分:18)

我有完全相同的问题,但“找不到模块'玉'',而不是'玉〜';我很确定我已经做过“npm install jade”。经过一段时间的研究,我发现我的问题是因为我在本地安装了jade全局安装,参考了这个帮助https://www.openshift.com/forums/express/nodejs-and-jade-error-cannot-find-module-jade我解决了我的问题..我在这里发布它认为它可能会帮助其他人面对面和我一样的问题:)

答案 2 :(得分:11)

对我来说,这个问题被证明是不同的。 我已经安装了玉器,并在本地和全球范围内表达,希望他们能以某种方式找到对方,但仍然表示抱怨玉器。

我的错误看起来像这样:

Express server listening on port 3000
Error: Cannot find module 'jade'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at new View (/Users/ajeetganga/node_modules/express/lib/view.js:43:49)
    at Function.app.render (/Users/ajeetganga/node_modules/express/lib/application.js:488:12)
    at ServerResponse.res.render (/Users/ajeetganga/node_modules/express/lib/response.js:798:7)
    at exports.index (/Users/ajeetganga/Documents/WORKSPACE/TinyUrl/MyTinyUrl2/routes/index.js:7:7)
    at callbacks (/Users/ajeetganga/node_modules/express/lib/router/index.js:164:37)
    at param (/Users/ajeetganga/node_modules/express/lib/router/index.js:138:11)

如果你观察到这一行:

at new View (/Users/ajeetganga/node_modules/express/lib/view.js:43:49)

您将看到它不是全局或本地的npm安装的默认位置。 所以作为一种解决方法,我在以下文件夹中安装了玉器

cd /Users/ajeetganga/node_modules/
npm install jade

我认为即使我从文件夹/ Users / ajeetganga /安装了jade但从未尝试过它也会有用。 :)

答案 3 :(得分:5)

The issue was with Fedora-16我正在努力。编辑时创建的临时文件,即'index.jade~'未被清除,因此出现问题。

可以通过删除临时文件'index.jade〜'或通过将节点模块'jade'重命名为'jade~'来解决Fedora-16中的问题。强>

答案 4 :(得分:2)

呃,你几乎肯定只有require('jade~')只有require('jade')的简单拼写错误。检查您的明确app.engine('jade')行是另一个可能的嫌疑人。

答案 5 :(得分:2)

使用Emacs编辑玉文件后,我遇到了同样的问题。解决方案很简单:找到jade~文件并删除它。

答案 6 :(得分:0)

我遇到了同样的问题(我的打字稿+ webpack项目中的jade-loader)。我通过将jade-loader安装为peer-dependency来解决它。