流星,npm和请求

时间:2013-10-29 18:36:35

标签: node.js meteor npm

我正在使用meteor,我运行了npm安装请求来访问该库。一切似乎安装正确,但当我运行流星服务器时,我得到以下错误。有没有关于为什么会这样或如何解决它的消息?感谢。

While building the application:
node_modules/request/node_modules/node-uuid/test/test.html:1: bad formatting in HTML template
node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js:1:15: Unexpected token ILLEGAL
node_modules/request/node_modules/form-data/node_modules/combined-stream/test/run.js:1:15: Unexpected token ILLEGAL

供参考:

的test.html

<html>
  <head>
    <style>
      div {
        font-family: monospace;
        font-size: 8pt;
      }
      div.log {color: #444;}
      div.warn {color: #550;}
      div.error {color: #800; font-weight: bold;}
    </style>
    <script src="../uuid.js"></script>
  </head>
  <body>
    <script src="./test.js"></script>
  </body>
</html>

run.js(同)

#!/usr/bin/env node
var far = require('far').create();

far.add(__dirname);
far.include(/test-.*\.js$/);

far.execute();

2 个答案:

答案 0 :(得分:1)

Meteor构建整个DOM本身,因此它通常会拒绝html中包含的任何脚本标记(但它会包括头部的脚本,感谢Andrew)。它也只支持手柄样式模板(现在)。

<html>
  <head>
  <title>Something</title>
  </head>
  <body>
    {{>yourHandlebarsTemplate}}
  </body>
</html>

我的建议是将你的js和css作为文件放在项目根目录下的客户端文件夹中。

至于NPM请求,您将无法:

  1. 正常安装它就像你在大多数节点项目中一样,所以node_module是out / npm install require out out
  2. 在没有Npm.require
  3. 的情况下访问其中的功能

    此时您有两个选择:从Atmosphere(非官方软件包存储库)添加软件包NPM并包含请求。或者尝试将lib放入/ packages /然后使用Npm.require('request')。

    或者你可以使用Meteor的内置HTTP包(meteor add http),其功能类似于请求。

答案 1 :(得分:0)

从模板中删除,因为Meteor想要在构建模板时为您创建此标记。这应该在test.html中处理“HTML模板中的格式错误”错误。