meteor,npm和请求

我使用meteor,我运行npm安装请求来访问该库。 一切似乎安装正确,但是当我运行meteor服务器,然后我得到以下错误。 有没有关于为什么这个或如何解决它的话? 谢谢。

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> 

我的build议是让您的js和css位于项目根目录下的客户端文件夹内。

至于NPM的要求,你将无法:

  1. 像在大多数节点项目中一样正常安装它,所以node_module不在/ npm install require中
  2. 访问其中的function,而不需要Npm.require

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

另外,你也可以使用Meteor内置的HTTP包(meteor add http),其function类似于请求。

从模板中移除,因为Meteor想要在构build模板时为您创build此标记。 这应该照顾test.html中的“HTML模板格式不正确”错误。