简体   繁体   English

npm 安装 jquery 失败

[英]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 jquery@1.6.3 SyntaxError: Unexpected token ILLEGAL
npm ERR! error installing jquery@1.6.3 <html><title>Request timeout</title><body><h1>Request timeout</h1></body></html>
npm ERR! error installing jquery@1.6.3     at Object.parse (native)
npm ERR! error installing jquery@1.6.3     at Request._callback (/usr/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:147:21)
npm ERR! error installing jquery@1.6.3     at Request.callback (/usr/local/lib/node_modules/npm/node_modules/request/main.js:99:22)
npm ERR! error installing jquery@1.6.3     at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:361:18)
npm ERR! error installing jquery@1.6.3     at Request.emit (events.js:64:17)
npm ERR! error installing jquery@1.6.3     at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:327:16)
npm ERR! error installing jquery@1.6.3     at IncomingMessage.emit (events.js:81:20)
npm ERR! error installing jquery@1.6.3     at HTTPParser.onMessageComplete (http.js:133:23)
npm ERR! error installing jquery@1.6.3     at CleartextStream.ondata (http.js:1228:22)
npm ERR! error installing jquery@1.6.3     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!     <npm-@googlegroups.com>
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

I had the same problem.我有同样的问题。 Looks like we have to use看起来我们必须使用

npm install jQuery npm 安装 jQuery

instead of代替

npm install jquery npm 安装 jquery

Thanks to coolaj86 .感谢coolaj86

It seems like the camel case jQuery is depreciated now似乎骆驼案例jQuery现在贬值了

npm WARN deprecated jQuery@1.7.4: This is deprecated. Please use 'jquery' (all lowercase).

You got to use你得用

npm install jquery

On ubuntu, I added 'sudo':在 ubuntu 上,我添加了“sudo”:

sudo npm install jquery 

... that solved it for me. ......这为我解决了它。

To include jQuery in Node, first install with npm.要在 Node 中包含 jQuery,首先使用 npm 安装。

npm install jquery

For jQuery to work in Node, a window with a document is required.要使 jQuery 在 Node 中工作,需要一个带有文档的窗口。 Since no such window exists natively in Node, one can be mocked by tools such as jsdom.由于 Node 本身不存在这样的窗口,因此可以通过 jsdom 等工具进行模拟。 This can be useful for testing purposes.这对于测试目的很有用。

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

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

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

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