【问题标题】:Meteor simple-todos tut - Step 2 - Uncaught Error Cannot find module './template.body.jsMeteor simple-todos tut - 第 2 步 - 未捕获的错误找不到模块 './template.body.js
【发布时间】:2016-12-18 00:59:31
【问题描述】:

我创建了一个 debian 虚拟机,并在其中安装了 meteor 版本 1.4.2。

我正在编写 simple-todos 流星教程,火焰视图。

我已经完成了第 2 步的所有操作 [几次;甚至到了多次删除和重新开始的地步];我什至已经将所有代码直接 c&p 到各种文件中。我花了几个小时搜索谷歌; git-hub 和 stackoverflow 并没有找到任何与我的问题相关的内容。

当我在浏览器中查看应用程序时,页面是空白的……当我在控制台中查看时,出现以下错误代码:

Uncaught Error: Cannot find module './template.body.js'
    at require (http://localhost:3000/packages/modules-runtime.js?hash=ab7e8d32b6c7b5a5fa7ae1b65e8225c4f9e30223:119:19) [this error continues with a lot more references and hashes, but I can't post more than 2 links]

如果有人至少可以为我指出正确的方向,以便我继续研究,我将不胜感激。

【问题讨论】:

  • 您找到解决方案了吗?我也遇到了这个问题。
  • 是的,请参阅下面的回复。谢谢!

标签: javascript meteor module


【解决方案1】:

好吧,这很奇怪……我复制了你所看到的。当您在进行此编码时有流星 RUNNING 时会发生这种情况,因此它正在进行实时代码更新,但模块未正确构建/包含。

我所做的只是停止并重新启动 Meteor。它奏效了。

不知道为什么它没有在重建和热代码推送中加载模块,但你有它,这就是修复。

这是我的外壳,所以你看看我做了什么:

shaunst:~/workspace $ curl https://install.meteor.com/ | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7784    0  7784    0     0  23942      0 --:--:-- --:--:-- --:--:-- 23950
Downloading Meteor distribution
######################################################################## 100.0%

Meteor 1.4.2 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
This may prompt for your password.

To get started fast:

  $ meteor create ~/my_cool_app
  $ cd ~/my_cool_app
  $ meteor

Or see the docs at:

  docs.meteor.com

shaunst:~/workspace $ meteor create simple-todos
Created a new Meteor app in 'simple-todos'.                                        

To run your new app:                          
  cd simple-todos                             
  meteor                                      

If you are new to Meteor, try some of the learning resources here:
  https://www.meteor.com/learn                

shaunst:~/workspace $ cd simple-todos/        
shaunst:~/workspace/simple-todos $ meteor npm install
simple-todos@ /home/ubuntu/workspace/simple-todos
└─┬ meteor-node-stubs@0.2.3 
  ├── assert@1.3.0 
  ├─┬ browserify-zlib@0.1.4 
  │ └── pako@0.2.8 
  ├─┬ buffer@4.5.1 
  │ ├── base64-js@1.1.2 
  │ ├── ieee754@1.1.6 
  │ └── isarray@1.0.0 
  ├─┬ console-browserify@1.1.0 
  │ └── date-now@0.1.4 
  ├── constants-browserify@1.0.0 
  ├─┬ crypto-browserify@3.11.0 
  │ ├─┬ browserify-cipher@1.0.0 
  │ │ ├─┬ browserify-aes@1.0.6 
  │ │ │ ├── buffer-xor@1.0.3 
  │ │ │ └── cipher-base@1.0.2 
  │ │ ├─┬ browserify-des@1.0.0 
  │ │ │ ├── cipher-base@1.0.2 
  │ │ │ └─┬ des.js@1.0.0 
  │ │ │   └── minimalistic-assert@1.0.0 
  │ │ └── evp_bytestokey@1.0.0 
  │ ├─┬ browserify-sign@4.0.0 
  │ │ ├── bn.js@4.11.1 
  │ │ ├── browserify-rsa@4.0.1 
  │ │ ├─┬ elliptic@6.2.3 
  │ │ │ ├── brorand@1.0.5 
  │ │ │ └── hash.js@1.0.3 
  │ │ └─┬ parse-asn1@5.0.0 
  │ │   ├─┬ asn1.js@4.5.2 
  │ │   │ └── minimalistic-assert@1.0.0 
  │ │   ├─┬ browserify-aes@1.0.6 
  │ │   │ ├── buffer-xor@1.0.3 
  │ │   │ └── cipher-base@1.0.2 
  │ │   └── evp_bytestokey@1.0.0 
  │ ├─┬ create-ecdh@4.0.0 
  │ │ ├── bn.js@4.11.1 
  │ │ └─┬ elliptic@6.2.3 
  │ │   ├── brorand@1.0.5 
  │ │   └── hash.js@1.0.3 
  │ ├─┬ create-hash@1.1.2 
  │ │ ├── cipher-base@1.0.2 
  │ │ ├── ripemd160@1.0.1 
  │ │ └── sha.js@2.4.5 
  │ ├── create-hmac@1.1.4 
  │ ├─┬ diffie-hellman@5.0.2 
  │ │ ├── bn.js@4.11.1 
  │ │ └─┬ miller-rabin@4.0.0 
  │ │   └── brorand@1.0.5 
  │ ├── inherits@2.0.1 
  │ ├── pbkdf2@3.0.4 
  │ ├─┬ public-encrypt@4.0.0 
  │ │ ├── bn.js@4.11.1 
  │ │ ├── browserify-rsa@4.0.1 
  │ │ └─┬ parse-asn1@5.0.0 
  │ │   ├─┬ asn1.js@4.5.2 
  │ │   │ └── minimalistic-assert@1.0.0 
  │ │   ├─┬ browserify-aes@1.0.6 
  │ │   │ ├── buffer-xor@1.0.3 
  │ │   │ └── cipher-base@1.0.2 
  │ │   └── evp_bytestokey@1.0.0 
  │ └── randombytes@2.0.3 
  ├── domain-browser@1.1.7 
  ├── events@1.1.0 
  ├─┬ http-browserify@1.7.0 
  │ ├── Base64@0.2.1 
  │ └── inherits@2.0.1 
  ├── https-browserify@0.0.1 
  ├── os-browserify@0.2.1 
  ├── path-browserify@0.0.0 
  ├── process@0.11.2 
  ├── punycode@1.4.1 
  ├── querystring-es3@0.2.1 
  ├─┬ readable-stream@2.0.6 
  │ ├── core-util-is@1.0.2 
  │ ├── inherits@2.0.1 
  │ ├── isarray@1.0.0 
  │ ├── process-nextick-args@1.0.6 
  │ └── util-deprecate@1.0.2 
  ├─┬ stream-browserify@2.0.1 
  │ └── inherits@2.0.1 
  ├── string_decoder@0.10.31 
  ├── timers-browserify@1.4.2 
  ├── tty-browserify@0.0.0 
  ├─┬ url@0.11.0 
  │ ├── punycode@1.3.2 
  │ └── querystring@0.2.0 
  ├─┬ util@0.10.3 
  │ └── inherits@2.0.1 
  └─┬ vm-browserify@0.0.4 
    └── indexof@0.0.1 

shaunst:~/workspace/simple-todos $ meteor --port 8080
[[[[[ ~/workspace/simple-todos ]]]]]          

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:8080/
=> Meteor server restarted                    
=> Meteor server restarted                    
=> Meteor server restarted                    
=> Meteor server restarted                    
=> Client modified -- refreshing (x3)
=> Meteor server restarted                    
=> Meteor server restarted                    
=> Client modified -- refreshing^C
shaunst:~/workspace/simple-todos $ ^C
shaunst:~/workspace/simple-todos $ meteor --port 8080
[[[[[ ~/workspace/simple-todos ]]]]]          

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:8080/
=> Client modified -- refreshing (x2)

【讨论】:

  • 太棒了...非常感谢您的回复!抱歉,我今天之前没有看到这个。
【解决方案2】:

我也有同样的经历。 我按照用户 Shaun Stoltz 的建议(重新启动 Meteor)做了,它确实有效。但后来我在导入文件夹中添加了更多文件,错误再次出现,现在引用缺少“模板...”的新文件。

我再次重新启动 Meteor,构建再次运行。似乎流星在观看时忽略了构建中的新文件。只有在重新启动时才会包含新文件。这是一个真正的麻烦,因为在遵循现代组件方法时,我将创建许多小文件,并且反复重新启动 Meteor 会耗尽。

是否有其他用户遇到此问题?

【讨论】:

    【解决方案3】:

    将项目的 Meteor 版本设置为以前的版本:

    meteor update --release 1.4.1.3
    

    (感谢diaconutheodor

    Source

    【讨论】:

    • 谢谢!这个我也试试!
    【解决方案4】:

    我正在使用 blaze 模板在 Mac 上运行流星。我已经完成了以下步骤并且效果很好:

    • 确保 import 语句在 client/main.js 中而不是在 服务器/main.js
    • 确保已安装“blaze-html-templates”
    • 确保导入文件夹输入正确
    • 重启服务器
    • 如果一切都失败了,您可以使用“meteor reset”重置您的项目

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2016-07-11
      • 2021-11-24
      • 2015-11-22
      • 2018-12-01
      • 1970-01-01
      • 2022-10-25
      • 2022-08-13
      • 2016-10-24
      • 2018-02-25
      相关资源
      最近更新 更多