繁体   English   中英

流星,npm和请求

[英]Meteor, npm, and request

我正在使用流星,并且运行了npm install请求来访问该库。 一切似乎都正确安装,但是当我运行流星服务器时,我得到以下错误。 关于这是为什么还是如何解决有什么说法吗? 谢谢。

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();

Meteor构造了整个DOM本身,因此通常会拒绝html中包含的任何脚本标签(但感谢Andrew,它将在头中包含脚本)。 它还仅支持车把样式模板(现在)。

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

我的建议是将您的js和CSS作为文件放在项目根目录下的client文件夹中。

对于NPM请求,您将不能:

  1. 像在大多数节点项目中一样,通常进行安装,因此node_module已用完/ npm安装要求已用完
  2. 无需Npm.require即可访问其中的功能

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

另外,您可以只使用Meteor内置的HTTP程序包(meteor add http),其功能类似于request。

从您的模板中删除,因为Meteor似乎希望在构建模板时为您创建此标签。 这应该解决test.html中的“ HTML模板格式错误”错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM