nodejs最开始操作

来源:互联网 发布:面试测评软件系统 编辑:程序博客网 时间:2024/05/20 10:11

1.网上下载安装包 

http://nodejs.cn/ 后缀为.msi的

2.点击安装

一直默认,安装地址选一个好写的,比如F:/nodejs,到自定义设置的时候选择第四个 ADD to PATH,然后完成。

3.检测是否成功

cmd,node -v

4.hello world

随便一个文件夹,建一个文件hello.js

var http = require("http");  http.createServer(function(request, response) {        response.writeHead(200, {"Content-Type": "text/plain"});        response.write("Hello World");        response.end();  }).listen(8888);  console.log("nodejs start listen 8888 port!");  

cmd运行

F:\

cd f:\hello\

node hello.js

打开地址http://127.0.0.1:8888/ 即可看到

5.NPM

启动npm,我试了下普通的不成功,于是

cmd运行

先到你要操作的那个目录,然后

npm config set registry https:\\registry.npm,taobao.org

再npm instrall





原创粉丝点击