在 Eclipse 中安装 node.js 模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15446866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 13:53:00  来源:igfitidea点击:

Install node.js modules in eclipse

node.jseclipsesocket.ionode-modules

提问by Sashi

I am trying to develop a chat app with node.js and socket.io in an eclipse environment. I have installed node.js in eclipse but I don't know how to install node modules such as expresss, socket io, etc.

我正在尝试在 eclipse 环境中使用 node.js 和 socket.io 开发一个聊天应用程序。我在eclipse中安装了node.js但是不知道怎么安装expresss、socket io等node模块。

Please anyone tell me how to setup node modules in an eclipse environment.

请任何人告诉我如何在 Eclipse 环境中设置节点模块。

采纳答案by unzoomed

I dont think that there is an eclipse integrated way to do this. My suggestion is that you download node.js+npm from http://nodejs.org/download/and then open up a terminal/cmd and in your node.js project directory do "npm install myPackage"

我不认为有一个 eclipse 集成的方式来做到这一点。我的建议是你从http://nodejs.org/download/下载 node.js+npm ,然后打开一个终端/cmd,在你的 node.js 项目目录中执行“npm install myPackage”

回答by K. Siva Prasad Reddy

From https://groups.google.com/forum/#!topic/nodeclipse/FgUci2ZXpoQ

来自https://groups.google.com/forum/#!topic/nodeclipse/FgUci2ZXpoQ

  1. Double-click package.json on the Package Explorer to open it.
  2. Add into dependencies section what you want to install, and save it.
  3. Select package.json on the Package Explorer, open context menu by right-clicking, and select [Run As]-[npm install] menu.
  1. 双击 Package Explorer 上的 package.json 将其打开。
  2. 将要安装的内容添加到依赖项部分,然后保存。
  3. 在 Package Explorer 中选择 package.json,右键单击打开上下文菜单,然后选择 [Run As]-[npm install] 菜单。

回答by Duane

I'm running Eclipse Mars... Here is how I did it...

我正在运行 Eclipse Mars ......这是我是如何做到的......

  1. Install Nodeclipse from eclipse marketplace http://www.nodeclipse.org/
  2. Create a new node.js express project, File -> New Node.Js Express Project
  3. Open the package.json file
  4. Add my npm package to the package.json as a dependency (copy the format for the express dependency)
  5. Save the package.json(seems obvious but it got me when testing!)
  6. Right click the package.json, Run As -> NPM Install
  7. Right click the eclipse project folder, Refresh
  8. Open node_modules... BOOM! You will see your new module installed in eclipse
  1. 从 eclipse 市场http://www.nodeclipse.org/安装 Nodeclipse
  2. 创建一个新的 node.js express 项目,File -> New Node.Js Express Project
  3. 打开 package.json 文件
  4. 将我的 npm 包作为依赖添加到 package.json 中(复制 express 依赖的格式)
  5. 保存 package.json(看起来很明显,但在测试时让我知道了!)
  6. 右键单击 package.json,运行方式 -> NPM 安装
  7. 右键单击eclipse项目文件夹,Refresh
  8. 打开 node_modules ... BOOM!你会看到你的新模块安装在 eclipse 中

回答by sk8asd123

You mention installing express, but you don't need to install that if you're using nodeclipse.

您提到安装 express,但如果您使用的是 nodeclipse,则不需要安装它。

to generate an express project: Select the File-New-Project menu. Select Node-Express Project, and select Next button. Enter Project name and select Finish button.

生成一个 express 项目:选择 File-New-Project 菜单。选择 Node-Express Project,然后选择 Next 按钮。输入项目名称并选择完成按钮。

回答by Pradeep

To install express modules in Nodeclipse go to

要在 Nodeclipse 中安装 express 模块,请转到

Windows -> Preferences-> Nodeclipse -> choose express path field

Windows -> Preferences-> Nodeclipse -> 选择 express path 字段

and enter the location of the installed express on your localhost.

并在本地主机上输入安装的 express 的位置。

回答by xan_z

Navigate to your project folder via command prompt. Once there, run the npm install 'module' command. After the module installs, refresh your project in eclipse. A javascript library should show up in your project containing the library of the module you just installed. Run your code and it should work and recognize the modules that your are trying to require. Hope this helps.

通过命令提示符导航到您的项目文件夹。在那里,运行 npm install 'module' 命令。模块安装后,在 eclipse 中刷新您的项目。一个 javascript 库应该出现在您的项目中,其中包含您刚刚安装的模块的库。运行您的代码,它应该可以工作并识别您尝试需要的模块。希望这可以帮助。