node.js 错误:找不到模块“玉~”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15289558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 13:47:32  来源:igfitidea点击:

Error: Cannot find module 'jade~'

javascriptnode.jspugrailway.jscompoundjs

提问by Okky

Im new to node js. I used Compound Js to create a crud operation.

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

The app was working fine till i tried to alert a value, after that I'm getting the error

该应用程序运行良好,直到我尝试提醒一个值,之后我收到错误

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)

How to resolve this

如何解决这个问题

My index

我的索引

#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.
    - } 

Layout file

布局文件

!!! 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')

采纳答案by Okky

The issue was with Fedora-16that i was working on. The temp file created while editing ie., 'index.jade~' was not cleared and thus the issue came.

The issue was with Fedora-16我正在做的。编辑时创建的临时文件,即 'index.jade~' 没有被清除,因此问题来了。

The issue can be resolved in Fedora-16 by either deleting the temp file 'index.jade~'or by renaming the node module 'jade' to 'jade~'

在 Fedora-16 中可以通过删除临时文件“index.jade~”将节点模块“jade”重命名为“jade~”来解决该问题

回答by jeff fried

I had the same problem in the nodeschool expressworks tutorial. I solved it by including the dependencies in package.json:

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

npm install --save express jade

回答by Duc To

I have quite the same issue but "Cannot find module 'jade'", not 'jade~'; and I pretty sure that I already did "npm install jade". After awhile of research, I found out that my problem because I install express globally while jade is installed locally, referenced to this help https://www.openshift.com/forums/express/nodejs-and-jade-error-cannot-find-module-jadeI solved my problem.. I post it here thinking that it might help some others whom face the same issue as me :)

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

回答by Ajeet Ganga

For me this was the issue turned out to be different. I had installed jade and express both locally and globally in hope they will find each other somehow, but still express was complaining about the jade.

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

My error looked like this :

我的错误是这样的:

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)

if you observe this line :

如果你观察这条线:

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

You will see that it is not the default location for npm installation for global or local .. So as a work around, i installed jade in following folder

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

cd /Users/ajeetganga/node_modules/
npm install jade

I think it would have worked even if I would have installed jade from the folder /Users/ajeetganga/ but never tried. :)

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

回答by Peter Lyons

Uh, you almost certainly have require('jade~')with a simple typo where you want just require('jade'). Check your express app.engine('jade')line as another likely suspect.

呃,你几乎肯定有require('jade~')一个简单的错字,你想要的只是require('jade'). 检查您的快递app.engine('jade')线路是否是另一个可能的嫌疑人。

回答by Yale Huang

I got the same issue after editing a jade file with Emacs. The solution is quite simple: find the jade~ file and delete it.

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

回答by Ihor Pavlyk

I had the same issue (jade-loader in my typescript + webpack project). I resolved it by installing jade-loader as peer-dependency.

我有同样的问题(我的打字稿 + webpack 项目中的 jade-loader)。我通过安装 jade-loader 作为对等依赖来解决它。