Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 无法在Ubuntu 13.x中卸载express_Node.js_Express - Fatal编程技术网

Node.js 无法在Ubuntu 13.x中卸载express

Node.js 无法在Ubuntu 13.x中卸载express,node.js,express,Node.js,Express,我已经安装了express,但它不再工作。当我在终端中键入“express”时,我得到: bash: /usr/local/bin/express: No such file or directory 如果我尝试卸载,我会得到 sudo npm uninstall –g express npm WARN uninstall not installed in /home/user/expressApps/sausage/node_modules: "–g" npm WARN uninstall

我已经安装了express,但它不再工作。当我在终端中键入“express”时,我得到:

bash: /usr/local/bin/express: No such file or directory
如果我尝试卸载,我会得到

sudo npm uninstall –g express
npm WARN uninstall not installed in /home/user/expressApps/sausage/node_modules: "–g"
npm WARN uninstall not installed in /home/user/expressApps/sausage/node_modules: "express"
sudo npm install –g express
npm WARN package.json application-name@0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/express/3.12.1
npm http GET https://registry.npmjs.org/%E2%80%93g
npm http 404 https://registry.npmjs.org/%E2%80%93g
npm ERR! 404 '%E2%80%93g' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

npm ERR! System Linux 3.11.0-24-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "–g" "express"
npm ERR! cwd /home/johnmlocklear/expressApps/sausage
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! code E404
npm http 304 https://registry.npmjs.org/express/3.12.1
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/johnmlocklear/expressApps/sausage/npm-debug.log
npm ERR! not ok code 0
或者如果我尝试重新安装,我会

sudo npm uninstall –g express
npm WARN uninstall not installed in /home/user/expressApps/sausage/node_modules: "–g"
npm WARN uninstall not installed in /home/user/expressApps/sausage/node_modules: "express"
sudo npm install –g express
npm WARN package.json application-name@0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/express/3.12.1
npm http GET https://registry.npmjs.org/%E2%80%93g
npm http 404 https://registry.npmjs.org/%E2%80%93g
npm ERR! 404 '%E2%80%93g' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

npm ERR! System Linux 3.11.0-24-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "–g" "express"
npm ERR! cwd /home/johnmlocklear/expressApps/sausage
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! code E404
npm http 304 https://registry.npmjs.org/express/3.12.1
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/johnmlocklear/expressApps/sausage/npm-debug.log
npm ERR! not ok code 0

如何让express重新工作?

我的主要线索在以下错误行中:

npm http GET https://registry.npmjs.org/%E2%80%93g
npm http 404 https://registry.npmjs.org/%E2%80%93g
npm ERR! 404 '%E2%80%93g' is not in the npm registry.
%E2%80%93g
(注意末尾的
g
)看起来很疯狂。它似乎直接连接到这条线路上:

sudo npm install –g express
g
旁边的
-
不是一个简单的破折号,而是一些经过url编码的UTF-8字符。非常确定,因为url编码的
%E2%80%93
等于
e28093
十六进制。这很可能来自文本编辑器的复制和粘贴,该编辑器以某种方式自动将简单虚线设置为en虚线。存储代码时要小心这样的东西&作弊

要修复此问题,请使用实际破折号运行命令,如下所示:

sudo npm install -g express
我看到的另一个问题是:

bash:/usr/local/bin/express:没有这样的文件或目录


那么
/usr/local/bin/express
从哪里来?如果
express
不在您的路径中,那么您甚至不会收到这样的完整路径消息?您的个人资料中是否有
bash
别名?如果您自己设置,我强烈建议只将
/usr/local/bin/
添加到您的shell路径,而不是设置别名。

因此我认为我的问题是我使用

sudo apt-get install express
在那之后的某个时候,我也从npm安装了。为了清理这一切,我跑了

sudo apt-get uninstall express
…我还进入了~/.npm并删除了express和express Generator文件夹。然后我跑了两个

sudo npm install -g express
sudo npm install -g express-generator

…现在一切似乎都正常了。

很高兴事情解决了!但是关于我的答案被发现的
sudo-nom-uninstall–g express
问题呢?在你的命令中,这绝对是一个URL编码的
en-dash
。这解决了我的问题,谢谢,还有一个问题。但还有一件事,我使用npm安装了npm。。这很奇怪,但这是我可以正确安装npm的唯一方法
sudo npm install npm