express

win7 express js: 'express' is not recognized in cmd

[亡魂溺海] 提交于 2020-01-01 10:28:32
问题 I have node.js installed and running fine on windows 7 computer. I run > npm install -g express > npm install -g express-generator > npm install -g express-generator@3 and they all install successfully. But when I go to a new folder and try: > express myproject I get: 'express' is not recognized as an internal or external command, operable program or batch file I see 'express', 'express.cmd', and 'node_modules' directory with 'express' and 'express-generator' folders in the C:\Users\ME

win7 express js: 'express' is not recognized in cmd

非 Y 不嫁゛ 提交于 2020-01-01 10:28:07
问题 I have node.js installed and running fine on windows 7 computer. I run > npm install -g express > npm install -g express-generator > npm install -g express-generator@3 and they all install successfully. But when I go to a new folder and try: > express myproject I get: 'express' is not recognized as an internal or external command, operable program or batch file I see 'express', 'express.cmd', and 'node_modules' directory with 'express' and 'express-generator' folders in the C:\Users\ME

How can I serve static web site from s3 through node expressjs?

巧了我就是萌 提交于 2020-01-01 09:56:28
问题 currently I use app.use(express.static('public')) and my files located in the public folder of my node js express app and its working good. However, I would like to store those files (index.html, etc) in my s3 bucket (so multiple apps can use this website). I tried app.get('/', function(req, res) { res.sendfile('link-to-s3-file/index.html'); }); with no success... 回答1: I wouldn't reinvent the wheel. There's a reasonably recent and well documented middleware module for this on npm From the

Node, Express, Ajax, and Jade Example

我怕爱的太早我们不能终老 提交于 2020-01-01 09:52:57
问题 I'm looking for a simple example of a Node/Express/Jade page being updated using an Ajax call with both the client and server side code. I'm having a bit of trouble putting it all together in my head. 回答1: There are great many ways this could be done and it's not immediately apparent which approach you want to take. I suppose the simplest scenario would be to add some client-side logic to fetch pieces of html from the server and update the client. This is easily achieved using jQuery (put it

Node, Express, Ajax, and Jade Example

瘦欲@ 提交于 2020-01-01 09:51:52
问题 I'm looking for a simple example of a Node/Express/Jade page being updated using an Ajax call with both the client and server side code. I'm having a bit of trouble putting it all together in my head. 回答1: There are great many ways this could be done and it's not immediately apparent which approach you want to take. I suppose the simplest scenario would be to add some client-side logic to fetch pieces of html from the server and update the client. This is easily achieved using jQuery (put it

Change URL after POST using ExpressJS

╄→尐↘猪︶ㄣ 提交于 2020-01-01 09:38:05
问题 I use expressJS as my NodeJS server. The user sends me his login info through a POST and after checking the credentials I render a page: router.post("/login", function (req: Request, res: Response, next) { if(credentialsOK){ res.render('main'); } }); The problem is that the URL becomes http://myaddress/login and I would like to remove the /login of the address. I don't want to use redirect as I want to send local variables through the render. How can I change the URL? 回答1: You can still pass

How can I use a javascript library on the server side of a NodeJS app when it was designed to run on the client?

你离开我真会死。 提交于 2020-01-01 09:36:06
问题 I'm diving into NodeJS and Express (it's sooo complicated to me) to build a real-time web app. At the moment, I'm trying to understand how I can use an existing javascript library on the server side. The problem is the library appears to be designed to run on the client side and, as a result, the instructions only show you how to use it on the client side. The library I'm talking about can be found here... https://github.com/replit/jsrepl Questions: Since a NodeJS web app is built on

Sails.js authorization for socket requests

浪子不回头ぞ 提交于 2020-01-01 09:15:13
问题 I'm trying to build a chat application based on sails.js. The url for messages from a specific chat looks like this: /api/chat/:id/messages When I request this url with XHR, it provides a session cookie and sails.js builds a session object. I can easily check user rights to read the messages from the specific chat. However, I need to request this url with socket.io so that the client can subscribe to all future changes of the messages collection. When I request this url with socket.io, no

typescript node.js express routes separated files best practices

荒凉一梦 提交于 2020-01-01 09:15:08
问题 using Express in a Node project along with Typescript what would be the "best practices" for express.Router. example directory structure |directory_name ---server.js |--node_modules |--routes ---index.ts |--admin ---admin.ts |--products ---products.ts |--authentication ---authentication.ts so inside index.ts it would encapsulate and manage all the sub-routers //admin.ts (nested inside of index.ts) import * as express from "express"; export = (() => { let router = express.Router(); router.get(

How to write Procfile for node.js heroku deployment using bin/www?

僤鯓⒐⒋嵵緔 提交于 2020-01-01 09:11:23
问题 I am trying to deploy a Heroku app, and I believe the procfile may be the reason my app is not deploying. I've tried multiple solutions including: web: node ./bin/www web: npm start There may be another reason my app is not working, but I want to make sure my Procfile is set up correctly 回答1: This is what I have: A file in the root directory of the project called Procfile (no file extension) Inside the file, the first line reads web: bin/web In the bin directory which is also located in the