---
title: "node eclipse不能运行js,一启动进程就中断"
author: "smiky"
date: "2014-05-13T10:25:21Z"
tags: []
categories: ["Web前端"]
slug: "node-eclipse-js"
draft: false
lastmod: "2014-05-13T10:25:21Z"
id: 2065653
url: "https://smiky.iteye.com/blog/2065653"
---

不管是用eclise安装nodejs插件还是直接下载nodeclipse，连最简单的demo都无法运行，一运就就出现环境变量及运行环境，接着就是node进程中断.

var http = require('http');

http.createServer(function (req, res) {

  res.writeHead(200, {'Content-Type': 'text/plain'});

  res.end('Hello World\\n');

}).listen(1337, '127.0.0.1');

console.log('Server running at http://127.0.0.1:1337/');

连这个最简单的hello world都不能运行。

 

相关的说法是JRE版本太低，升到1.7就没事了，我本地是1.6的。下面是我找的两个关于这个问题的说法:

http://stackoverflow.com/questions/21340527/nodeclipse-unable-to-run-even-the-simplest-app  
https://github.com/Nodeclipse/nodeclipse-1/issues/72

 

安装完JRE后要重启eclipse,我安装后在eclipse里面重设jre没生效，于是重启，发现好了，又将jre设回低版本发现还是正常，很奇怪，环境变量也没重设，时间有限，有兴趣的同学可以再试下。

 

 

如下图(这图来自这个贴子，http://bbs.csdn.net/topics/390775132?page=1#post-397373335，JRE装了之后就没这个信息了，懒得再去卸载了)

![](http://dl2.iteye.com/upload/attachment/0097/0570/b3596b8c-bb96-3b59-8dff-d83538c880b2.png)