简体   繁体   English

Node.js —找不到已安装模块的命令

[英]Node.js — Command not found for installed module

I had node, npm, and http-server installed and running. 我已经安装并正在运行节点,npm和http服务器。 However, when I tried to start up the http-server, I got the following error: 但是,当我尝试启动http服务器时,出现以下错误:

error: Cannot find module 'child-process-close

I have tried uninstalling and re-installing node. 我尝试卸载并重新安装节点。 That seemed to work just fine, and it looked like it installed http-server properly when I installed it globally with the following command: 看来一切正常,当我使用以下命令全局安装http-server时,它似乎已正确安装了http-server:

npm install -g http-server

However, when I tried to run the server on a directory (I even installed http-server locally in that directory), I get the following error: 但是,当我尝试在目录上运行服务器时(甚至在该目录中本地安装了http-server),都会出现以下错误:

zsh: command not found: http-server

When I run this command: 当我运行此命令时:

npm ls -g

I get: 我得到:

/Users/amckemie1/.node/lib
├─┬ http-server@0.7.4
│ ├── colors@1.0.3
│ ├─┬ ecstatic@0.5.8
│ │ ├── he@0.5.0
│ │ ├── mime@1.2.11
│ │ └── minimist@1.1.0
│ ├── opener@1.4.0
│ ├─┬ optimist@0.6.1
│ │ ├── minimist@0.0.10
│ │ └── wordwrap@0.0.2
│ ├─┬ portfinder@0.2.1
│ │ └── mkdirp@0.0.7
│ └─┬ union@0.4.4
│   └── qs@2.3.3
└─┬ npm@2.3.0

etc... 等等...

I can't figure out why it can't find the http-server module. 我不知道为什么找不到HTTP服务器模块。 I'm guessing it has something to do with my PATH or where the module was installed, but I don't know enough about these factors yet to be able to do much more. 我猜想它与我的PATH或模块的安装位置有关,但是我对这些因素还不了解,因此还无法做更多的事情。 Any ideas? 有任何想法吗?

I found the answer to this question here: Global Node modules not installing correctly. 我在这里找到了此问题的答案: 全局节点模块未正确安装。 Command not found 找不到相关命令

Brad Parks answer regarding resetting my node install prefix fixed it! 布拉德·帕克斯回答有关重置我的节点安装前缀的问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM