user592419
user592419

Reputation: 5223

Meteor, npm, and request

I'm using meteor and I ran npm install request to get access to that library. Everything seems to install correctly but when I run the meteor server, I then get the following error. Is there any word on why this is or how to solve it? Thanks.

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

For reference:

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

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

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

far.execute();

Upvotes: 1

Views: 2726

Answers (2)

Marco L&#252;thy
Marco L&#252;thy

Reputation: 1309

Remove from your template as it seems Meteor wants to create this tag for you when building the template. This should take care of the "bad formatting in HTML template" error in test.html.

Upvotes: 0

Pent
Pent

Reputation: 1049

Meteor constructs the entire DOM itself so it will typically reject any script tags included in the html (but it will include scripts in the head, thanks Andrew). It also only supports handlebars style templating (right now).

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

My advice would be to have your js and css located as files inside the client folder under your projects root.

As for NPM request, you will not be able to:

  1. install it normally like you do in most node projects, so node_module is out/npm install require is out
  2. access the functions in it without a Npm.require

At this point you have two options: adding the package NPM from Atmosphere(unofficial package repository) and including request. Or try placing the lib into /packages/ and then using Npm.require('request').

Alternatively you can just use Meteor's built in HTTP package (meteor add http) which functions similar to request.

Upvotes: 1

Related Questions