gpt4 book ai didi

node.js - npm install express-generator 没有安装 express

转载 作者:搜寻专家 更新时间:2023-11-01 00:23:23 25 4
gpt4 key购买 nike

我正在学习一个 MEAN 堆栈教程,该教程要求我快速安装:

我运行这个:

npm install -g express-generator

这是我的结果:

username@username-Inspiron-3521:~$ npm install -g express-generator
/home/username/npm/bin/express -> /home/username/npm/lib/node_modules/express-generator/bin/express
express-generator@4.13.1 /home/username/npm/lib/node_modules/express-generator
├── sorted-object@1.0.0
├── mkdirp@0.5.1 (minimist@0.0.8)
└── commander@2.7.1 (graceful-readlink@1.0.1)

但是当我这样做的时候

express --ejs flapper-news

The program 'express' is currently not installed. You can install it by typing:
sudo apt-get install node-express

我做错了什么?

感谢抽空。

编辑

当我执行 npm install

username@username-Inspiron-3521:~/Documents/mean/flapper_news$ npm install
npm ERR! install Couldn't read dependencies
npm ERR! Linux 3.16.0-51-generic
npm ERR! argv "/home/username/local/bin/node" "/home/username/local/bin/npm" "install"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! path /home/username/Documents/mean/flapper_news/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno -2
npm ERR! syscall open

npm ERR! package.json ENOENT: no such file or directory, open '/home/username/Documents/mean/flapper_news/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! Please include the following file with any support request:
npm ERR! /home/username/Documents/mean/flapper_news/npm-debug.log

edit2

在运行 npm install -g express 并输入 express -v 之后,我得到了这个:

bash:/usr/bin/express: 没有那个文件或目录

edit3

这是我的.bashrc 文件:

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
export PATH=$HOME/local/bin:$PATH
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/username/npm/lib/node_modules
export PATH=/home/username/Android/Sdk/platform-tools:$PATH
export PATH=/home/username/Android/Sdk/tools:$PATH

最佳答案

npm install -g express generator 的输出中查看这一行

/home/username/npm/bin/express -> /home/username/npm/lib/node_modules/express-generator/bin/express

您的 npm 正在您的主目录中安装全局模块,并将二进制链接放置在 /home/username/npm/bin 目录中,因此您需要将其添加到您的路径中。将此添加到您的 .bashrc:

export PATH=$HOME/npm/bin:$PATH

关于node.js - npm install express-generator 没有安装 express,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33445007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com