nodejs笔记--基础篇(一)

Sublime Node.js开发环境配置

下载并安装Node.js安装包后再开始配置

  1.先安装好Sublime Text 2

  2.运行Sublime,菜单上找到Tools ---> Build System ---> new Build System

  3.在文件中复制入

{
    "cmd": ["node", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.javascript"
}

      4.保存文件为NodeJs.sublime-build

  5.菜单上找到Tools ---> Build System --->选择 NodeJs

  6.安装Package Control;运行Sublime,按下快捷键Ctrl + `;在控制台中输入如下并回车;

sublime Text3
import urllib.request,os,hashlib; h = ‘eb2297e1a458f27d836c04bb0cbaf282‘ + ‘d0e7a3098092775ccb37ca9d6b2e4b7d‘; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( ‘http://packagecontrol.io/‘ + pf.replace(‘ ‘, ‘%20‘)).read(); dh = hashlib.sha256(by).hexdigest(); print(‘Error validating download (got %s instead of %s), please try manual install‘ % (dh, h)) if dh != h else open(os.path.join( ipp, pf), ‘wb‘ ).write(by)

sublime Text2
import urllib2,os,hashlib; h = ‘eb2297e1a458f27d836c04bb0cbaf282‘ + ‘d0e7a3098092775ccb37ca9d6b2e4b7d‘; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( ‘http://packagecontrol.io/‘ + pf.replace(‘ ‘, ‘%20‘)).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), ‘wb‘ ).write(by) if dh == h else None; print(‘Error validating download (got %s instead of %s), please try manual install‘ % (dh, h) if dh != h else ‘Please restart Sublime Text to finish installation‘)

详细请参考:https://sublime.wbond.net/installation#st2

  7.安装完成后重新启动Sublime,按下快捷键Ctrl + Shift + P; 输入install,选择Install Package并回车

  8.输入nodejs并选择Nodejs安装(可以装上JavaScript & NodeJs Snippets)

  9.新建test.js文件,输入 console.log(‘Hello Node.js‘); 

配置Sublime Node.js开发环境就成功了!

nodejs版本控制  nvmw(Node version manager for Windows)

安装命令:

npm install -g nvmw

Notes
It doesn‘t work in Windows Powershell
The latest version for npm is 1.4.12
You should install a system version Node with Windows installer

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。