您的位置:首页 > 运维架构 > Shell

《node.js 开发指南》bash: express: command not found

2018-01-31 17:04 597 查看
1)bash: express: command not found

$ npm install -g express 安装成功后,运行express –help 报bash: express: command not found

解决方法:npm install -g express-generator

2) express -t ejs microblog

express -t ejs microblog 安装后查看package.json,装的是jade,而不是esj。

解决方法:express -e microblog

3)app.js 没法启动

解决方法:npm start

4)创建/hello 页面

按照书本在app.js 后添加app.get(‘/hello’, routes.hello); 是没法实现的,然后index.js 后添加hello 函数

解决方案:app.use(‘/hello’, index);

router.get(‘/hello’, function(req, res, next) {

res.send(‘The time is ’ + new Date().toString());

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: