Soroush Hakami
Soroush Hakami

Reputation: 5406

npm install jquery fails

Tried reading this stacktrace thoroughly but it didn't make me any smarter. Ideas?

sudo npm install jquery

npm ERR! registry error parsing json
npm ERR! error installing [email protected] SyntaxError: Unexpected token ILLEGAL
npm ERR! error installing [email protected] <html><title>Request timeout</title><body><h1>Request timeout</h1></body></html>
npm ERR! error installing [email protected]     at Object.parse (native)
npm ERR! error installing [email protected]     at Request._callback (/usr/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:147:21)
npm ERR! error installing [email protected]     at Request.callback (/usr/local/lib/node_modules/npm/node_modules/request/main.js:99:22)
npm ERR! error installing [email protected]     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:361:18)
npm ERR! error installing [email protected]     at Request.emit (events.js:64:17)
npm ERR! error installing [email protected]     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:327:16)
npm ERR! error installing [email protected]     at IncomingMessage.emit (events.js:81:20)
npm ERR! error installing [email protected]     at HTTPParser.onMessageComplete (http.js:133:23)
npm ERR! error installing [email protected]     at CleartextStream.ondata (http.js:1228:22)
npm ERR! error installing [email protected]     at CleartextStream._push (tls.js:303:27)
npm ERR! registry error parsing json
npm ERR! SyntaxError: Unexpected token ILLEGAL
npm ERR! <html><title>Request timeout</title><body><h1>Request timeout</h1></body></html>
npm ERR!     at Object.parse (native)
npm ERR!     at Request._callback (/usr/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:147:21)
npm ERR!     at Request.callback (/usr/local/lib/node_modules/npm/node_modules/request/main.js:99:22)
npm ERR!     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:361:18)
npm ERR!     at Request.emit (events.js:64:17)
npm ERR!     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:327:16)
npm ERR!     at IncomingMessage.emit (events.js:81:20)
npm ERR!     at HTTPParser.onMessageComplete (http.js:133:23)
npm ERR!     at CleartextStream.ondata (http.js:1228:22)
npm ERR!     at CleartextStream._push (tls.js:303:27)
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>
npm ERR! 
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "jquery"
npm ERR! cwd /Users/fw/nodeprojects/cloudnode/zorro
npm ERR! node -v v0.4.10
npm ERR! npm -v 1.0.106
npm ERR! type unexpected_token
npm ERR! arguments [ 'ILLEGAL' ]
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/fw/nodeprojects/cloudnode/zorro/npm-debug.log
npm not ok

Upvotes: 3

Views: 10724

Answers (4)

David M
David M

Reputation: 311

To include jQuery in Node, first install with npm.

npm install jquery

For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as jsdom. This can be useful for testing purposes.

require("jsdom").env("", function(err, window) {
    if (err) {
        console.error(err);
        return;
    }

    var $ = require("jquery")(window);
});

Upvotes: -1

Efe Ariaroo
Efe Ariaroo

Reputation: 1080

On ubuntu, I added 'sudo':

sudo npm install jquery 

... that solved it for me.

Upvotes: -1

rand_mem_RAM
rand_mem_RAM

Reputation: 586

It seems like the camel case jQuery is depreciated now

npm WARN deprecated [email protected]: This is deprecated. Please use 'jquery' (all lowercase).

You got to use

npm install jquery

Upvotes: 2

Shahed
Shahed

Reputation: 898

I had the same problem. Looks like we have to use

npm install jQuery

instead of

npm install jquery

Thanks to coolaj86.

Upvotes: 11

Related Questions