Windows上的Node.js和Express [英] Node.js and Express on Windows

查看:124
本文介绍了Windows上的Node.js和Express的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今晚我决定尝试在Windows 7机器上使用Express构建一个简单的Node.js应用程序。安装相当顺利,但是Express拒绝合作。以下是我采取的步骤:


  1. 安装的Node.js使用MSI可用,位于 http://nodejs.org/dist/v0.6.9/node-v0.6.9.msi

  2. 通过从命令提示符运行 npm install express g 安装Express。

  3. 为应用程序创建一个目录 C:\source\\\
    ode> mkdir newapp

  4. 将目录更改为应用程序目录 c:\source\\\
    ode> cd newapp

  5. Ran Express: c:\source\\\
    ode\\\
    ewapp>快递 - 会话--css手写笔

此时,node.exe进程启动,以25%CPU时间无休止地运行,并持续使用更多的内存。运行20多分钟后,node.exe进程使用300+ MB的内存。 express 命令永远不会完成, newapp 目录保持不变。



如果我运行 express --help ,我在控制台中看到帮助输出。我已经尝试运行命令提示符和管理员,但仍然Express显示挂起。



有没有人知道发生了什么或我做错了什么?感谢提前!

解决方案

这是Windows v4.6.9版本的错误。文件系统访问几乎搞乱了。回滚到v0.6.8 http://nodejs.org/dist/v0。 6.8 / node-v0.6.8.msi ,你应该很好。



Windows上的Express.js命令行也不太好。我刚刚尝试使用Node v0.6.8。



这个工作

  express --sessions myapp 

这对我来说不起作用

  express --sessions --css手写笔myapp 

幸运的是,您可以添加手写笔支持手动在您生成的应用程序打开 app.js 并在 app.configure 函数中添加:



app.use(require('stylus')。middleware({src:__dirname +'/ public'}));



希望这有帮助!



更新:



哦,呵呵,别忘了你的NPM命令。在您的应用程序目录中,您可能需要 npm install jade npm install stylus


Tonight I decided I'd try to build a simple Node.js application using Express on my Windows 7 machine. The installation went fairly smoothly, but Express refuses to cooperate. Here are the steps I've taken:

  1. Installed Node.js using the MSI available at http://nodejs.org/dist/v0.6.9/node-v0.6.9.msi
  2. Installed Express by running npm install express g from a command prompt.
  3. Created a directory for the application c:\source\node> mkdir newapp.
  4. Changed directory to the application directory c:\source\node> cd newapp.
  5. Ran Express: c:\source\node\newapp> express --sessions --css stylus.

At this point the node.exe process fires up and runs endlessly at 25% CPU Time and continually uses more memory. After running for 20+ minutes the node.exe process uses 300+ MB of Memory. The express command never completes and the newapp directory remains unaltered.

If I run express --help I see the help output in the console. I've tried running the command prompt as and Administrator but still Express appears to hang.

Does anyone have a clue what's going on or what I'm doing wrong? Thanks in advance!

解决方案

This is a bug in the Windows version of Node v0.6.9. Filesystem access is pretty much messed up. Rollback to v0.6.8 http://nodejs.org/dist/v0.6.8/node-v0.6.8.msi and you should be fine.

The Express.js command line on Windows doesn't quite work well either. I just tried with Node v0.6.8.

This works

express --sessions myapp

This doesn't work for me

express --sessions --css stylus myapp

Fortunately you can add stylus support manually in your generated app. Open up app.js and in the app.configure function, add:

app.use(require('stylus').middleware({src: __dirname + '/public'}));

Hope this helps!

Update:

Oh ya, don't forget your NPM commands. In your app directory, you may need to npm install jade and npm install stylus.

这篇关于Windows上的Node.js和Express的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆