【nodejs】 npm 注意事项

时间:2023-03-08 23:03:02
【nodejs】 npm 注意事项

官网:https://www.npmjs.com/

1.安装时要切换到nodejs根目录,  否则就会安装到安装时所在的目录

2.要有管理员权限(win),如需指定版本,如npm install express@3.0.6

3.官方demo 提供比较全的依赖配置 http://www.hacksparrow.com/jquery-with-node-js.html

4.看一个demo

var $ = require('jquery');
var http = require('http'); var options = {
host: 'jquery.com',
port: 80,
path: '/'
}; var html = '';
http.get(options, function(res) {
res.on('data', function(data) {
// collect the data chunks to the variable named "html"
html += data;
}).on('end', function() {
// the whole of webpage data has been collected. parsing time!
var title = $(html).find('title').text();
console.log(title);
});
});
 
var jsdom = require("jsdom"); 
jsdom 4.x onward only works on io.js, not Node.js