最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - can not find module express --on windows - Stack Overflow

programmeradmin5浏览0评论

I use "npm install -g express" on windows console.but when I try to "node app.js", it shows me the error"can not find module express",I had set the environment variable"NODE_PATH",but nothing happen ,I need your help,Thank you!

I use "npm install -g express" on windows console.but when I try to "node app.js", it shows me the error"can not find module express",I had set the environment variable"NODE_PATH",but nothing happen ,I need your help,Thank you!

Share Improve this question asked Jan 25, 2013 at 15:58 Daniel.WooDaniel.Woo 6361 gold badge10 silver badges17 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 4

Globally installed modules aren't accessible without full path. You need to install express in your project directory or it parents. Check out documentation about module loading.

npm allows two options on how to install a module: locally and globally.

A global installation (done using npm install -g xyz) is for providing some tooling system-wide. Related to express this provides the global express bootstrapper that you can use to create an initial frame for your app by simply typing: express .. If you need help on what you can do with this mand, check out its help parameter: express --help.

In contrast, a local installation of a module provides this module for a specific app. A local installation is always made to an app's node_modules folder. When you try to require a module, Node.js searches the this folder for the requested module.

Hence, it is perfectly fine to have express installed multiple times: Once globally for the bootstrapper, multiple times locally (once per app).

So, to cut a long story short: To make your app run, install express locally using npm install express and that's it :-).

发布评论

评论列表(0)

  1. 暂无评论