Install node.js modules in eclipse

南笙酒味 提交于 2019-12-20 12:39:13

问题


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.

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


回答1:


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"




回答2:


From 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.



回答3:


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

  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



回答4:


You mention installing express, but you don't need to install that if you're using 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.




回答5:


To install express modules in Nodeclipse go to

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

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




回答6:


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.



来源:https://stackoverflow.com/questions/15446866/install-node-js-modules-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!