Giter Site home page Giter Site logo

expressjs / generator Goto Github PK

View Code? Open in Web Editor NEW
1.8K 1.8K 528.0 294 KB

Express' application generator

License: MIT License

CSS 0.17% HTML 0.26% JavaScript 94.54% Less 0.17% Sass 0.15% SCSS 0.20% Stylus 0.15% EJS 2.42% Handlebars 0.44% Pug 0.83% Twig 0.67%
express generator javascript nodejs

generator's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generator's Issues

change default template engine

Should we change the default to something other than jade? Something like hbs will let users use html out of the box versus learning a new language.

Just an observation from some feedback on getting a new user going with express.

generate an SSL project

could be handy to provide boilerplate for SSL integration, particularly because the server initialisation is abstracted out of app.js into ./bin/www

express -ssl -cert cert.pem -key key.pem

Make instructions more cmd.exe-friendly

After the generator has created a project, it displays this message:

run the app:
  $ DEBUG=myapp:* ./bin/www

Which is a bit cryptic for *nix beginners (I know it tripped me up)

Why not suggest npm start instead since it's already included in package.json?
(With maybe a separate note about setting the DEBUG environment variable)

Expresss Generator Does Not Do Anything

On a OpenVZ VM barebones within Ubuntu 14.04 running latest npm, nodejs from the repo, after installing installing express-generator globally, running express does not do anything. express command is valid but it does not output anything.

image

Add switch --nunjucks to add the Nunjucks template engine

This is by far my favorite template engine and it would be pretty sweet if this generator could automatically wire this up as the default template engine.

https://mozilla.github.io/nunjucks/

It is pretty simple to configure express.js to use nunjucks:

var app = express();

nunjucks.configure('views', {
    autoescape: true,
    express: app
});

app.get('/', function(req, res) {
    res.render('index.html');
});

(above snippet taken from https://mozilla.github.io/nunjucks/getting-started.html)

Node Sass Support

would love to see node sass be an option for the css engine options

Generated Express 4 app 404s with socket.io 1.0

socketio/socket.io#1556 (comment)

It seems like some of the error handling middleware the boilerplate of an express-generator app are forcing some socket.io calls to 404. (Not positive about that, but removing it seems to fix the problem)

The app was generated with express myapp --ejs on Mac OSX, testing with Google Chrome - I'm not super familiar with socket.io so I am not exactly sure what occurs, but it seems like for some reason the generated app is forcing socket.io to default to a different transport that it cannot load.

Improvements to the Generator

After a discussion (quite a while ago) with @dougwilson I've been thinking about how we could improve the boilerplate generator for express. The generator itself hasn't really gone through an overhaul since it was converted from a short script that concat'd a bunch of source together and outputted some files into a nice set of templates with improvements to the file structure.

With some large changes to the generator I think we can make express a lot better as a starting point for building your own tailored framework. Right now the choices you have for the generated code are fairly shallow. I think we can expand these choices to include what a lot of people are using express for. The changes are fairly large though.

Here is what I am thinking:

  • A preference file, allowing you to configure every aspect of the generated code. Here is an example
  • A set of templates that you can modify to generate code in your exact style.
  • The executable would take the preferences and templates as input and output an Express app.

Obviously there are a lot of specifics missing and the example preference file is fairly magic looking. So before I go much further with the idea I wanted to test the waters to see if this idea had any merit. Also there might be other ideas / projects underway that do this?

debug('Listening on ' + bind) doesn't output anything

In reference to the line in the generated bin/www

function onListening() {
  var addr = server.address();
  var bind = typeof addr === 'string'
    ? 'pipe ' + addr
    : 'port ' + addr.port;
  debug('Listening on ' + bind);
}

I never seem to get any output to my shell from this, even setting:

DEBUG=myapp node /bin/www 
โฏ npm run debug

> [email protected] debug /Users/kevinsuttle/Code/myapp
> DEBUG=myapp node bin/www

Am I totally doing this wrong?

include with express?

i still think it's nice to include this package with express, but i don't like it being in the same repo. is there a way to do that? don't dig a build process

Creating an app with -J option breaks app

It seems that the JSHTML support breaks by default:

~ $ express -V
3.4.8

~ $ express -J testapp
...

~ $ cd testapp && npm install
...

testapp $ node app
Express server listening on port 3000

# Make a request to localhost:3000, and then...
TypeError: Property 'engine' of object #<View> is not a function
    at View.render (/Users/bradb/testapp/node_modules/express/lib/view.js:76:8)
    at Function.app.render (/Users/bradb/testapp/node_modules/express/lib/application.js:504:10)
    at ServerResponse.res.render (/Users/bradb/testapp/node_modules/express/lib/response.js:798:7)
    at exports.index (/Users/bradb/testapp/routes/index.js:7:7)
    at callbacks (/Users/bradb/testapp/node_modules/express/lib/router/index.js:164:37)
    at param (/Users/bradb/testapp/node_modules/express/lib/router/index.js:138:11)
    at pass (/Users/bradb/testapp/node_modules/express/lib/router/index.js:145:5)
    at Router._dispatch (/Users/bradb/testapp/node_modules/express/lib/router/index.js:173:5)
    at Object.router (/Users/bradb/testapp/node_modules/express/lib/router/index.js:33:10)
    at next (/Users/bradb/testapp/node_modules/express/node_modules/connect/lib/proto.js:193:15)

Add option --static to generate static index.html over specifying a view template engine

I just wanted to run it by and see if it were okay to create a pull request for a --static option.
The use case is when I want to quickly generate an express project, but use it as a REST API only without using the views.

We create a static HTML file index.html and stick that into the public folder.
The same could be done for error.html.

The default route would just serve public/index.html.
I thought this it would be nice to not have to specify a view engine, but opt for static index.html.
I would love to work on this, but wanted to see if something like this would be acceptable.

Thanks!

READ.me instructions render "Error: listen EADDRINUSE"

I think the READ.me instructions are a bit unclear. I create a directory and was going through the REAM.me instruction, and it seems like the /tmp/foo gets created in the /private directory. If I run "npm start" from /tmp/foo where the package.json file is created, I get the following error:

[email protected] start /private/tmp/foo
node ./bin/www
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at Server.listen (net.js:1138:5)
at Function.app.listen (/private/tmp/foo/node_modules/express/lib/application.js:556:24)
at Object. (/private/tmp/foo/bin/www:7:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is most likely a problem with the foo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls foo
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "start"
npm ERR! cwd /private/tmp/foo
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.23
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/tmp/foo/npm-debug.log
npm ERR! not ok code 0

If I type in > npm owner ls foo, I see:

coolaj86 emailaddresshere

Does anyone know why this is happening?

Thanks.

Use given directory name as the app name by default

application-name and my-application are used by default in package.json and www respectively.

If a directory is provided we could use that by convention. If no directory is provided then could fallback to application-name.

add next param to the router function

in almost all the router functions doing db kind of operations, we want to do if (err) next(err);

next is used by almost all the router functions. I think it makes sense to add that as a param in the router functions generated by this generator.

How to set App in production mode

Hello,

I build my first node App with your great express-generator.
My question is how i can do to set my app in production mode (without all output in console, ...)
Thank you

express js fail, after npm start

Hi,

I tried to run the generator, but run into some errors.
(I'm on OS X 10.9.2, node, npm, express, everything is the latest)
There are no problems until npm start I get this in the prompt:

> [email protected] start /Users/szmarci/Sites/express
> node ./bin/www

Then I visit http://localhost:3000/, I get the Express test page (but unstyled) and immediately after this in the terminal:

GET / 304 982ms

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:998:11)
    at Process.ChildProcess._handle.onexit (child_process.js:789:34)

npm ERR! [email protected] start: `node ./bin/www`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is most likely a problem with the express package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./bin/www
npm ERR! You can get their info via:
npm ERR!     npm owner ls express
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "start"
npm ERR! cwd /Users/szmarci/Sites/express
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/szmarci/Sites/express/npm-debug.log
npm ERR! not ok code 0

I couldn't find any solution with google, tried to sudo, change port, etc.. but no luck.

Default error handler, next(), and ESLint's no unused var rule

This may be an Express-specific issue, but I'm trying to wrap my head around it.

Given the below code, ESLint complains that next is never used.

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

My questions:

  • Isn't next() implicitly called in Node middleware? I thought the best practice was to not call it explicitly in middleware.
  • If I do call it, it results in a crash by default. Using /foo as a test route.
    Calling next() by itself
// development error handlerโ€”will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
   next();
  });
}

console

GET /foo 404 28.361 ms - 16
_http_outgoing.js:335
    throw new Error('Can\'t set headers after they are sent.');
          ^
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:335:11)
    at ServerResponse.header (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/response.js:700:10)
    at ServerResponse.send (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/response.js:154:12)
    at Stub.fn [as callback] (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/response.js:934:10)
    at Stub.flush (/Users/kevinsuttle/Code/REDACTED/node_modules/dustjs-linkedin/lib/dust.js:567:10)
    at Chunk.end (/Users/kevinsuttle/Code/REDACTED/node_modules/dustjs-linkedin/lib/dust.js:704:15)
    at done (/Users/kevinsuttle/Code/REDACTED/node_modules/dustjs-linkedin/lib/dust.js:177:75)
    at /Users/kevinsuttle/Code/REDACTED/node_modules/consolidate/lib/consolidate.js:100:5
    at fs.js:334:14
    at FSReqWrap.oncomplete (fs.js:95:15)
18 May 12:52:23 - [nodemon] app crashed - waiting for file changes before starting...

browser

Cannot GET /foo

Calling next(err)

// development error handlerโ€”will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err
    });
    next(err)
  });
}

browser

Error: Not Found
   at /Users/kevinsuttle/Code/REDACTED/app.js:56:12
   at Layer.handle [as handle_request] (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/layer.js:82:5)
   at trim_prefix (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:302:13)
   at /Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:270:7
   at Function.proto.process_params (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:321:12)
   at next (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:261:10)
   at csrf (/Users/kevinsuttle/Code/REDACTED/middleware/utilities.js:5:2)
   at Layer.handle [as handle_request] (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/layer.js:82:5)
   at trim_prefix (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:302:13)
   at /Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:270:7

console

Error: Not Found
    at /Users/kevinsuttle/Code/REDACTED/app.js:56:12
    at Layer.handle [as handle_request] (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/layer.js:82:5)
    at trim_prefix (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:302:13)
    at /Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:270:7
    at Function.proto.process_params (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:321:12)
    at next (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:261:10)
    at csrf (/Users/kevinsuttle/Code/REDACTED/middleware/utilities.js:5:2)
    at Layer.handle [as handle_request] (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/layer.js:82:5)
    at trim_prefix (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:302:13)
    at /Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/router/index.js:270:7
GET /404 404 21.206 ms - 1150
_http_outgoing.js:335
    throw new Error('Can\'t set headers after they are sent.');
          ^
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:335:11)
    at ServerResponse.header (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/response.js:700:10)
    at ServerResponse.send (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/response.js:154:12)
    at Stub.fn [as callback] (/Users/kevinsuttle/Code/REDACTED/node_modules/express/lib/response.js:934:10)
    at Stub.flush (/Users/kevinsuttle/Code/REDACTED/node_modules/dustjs-linkedin/lib/dust.js:567:10)
    at Chunk.end (/Users/kevinsuttle/Code/REDACTED/node_modules/dustjs-linkedin/lib/dust.js:704:15)
    at done (/Users/kevinsuttle/Code/REDACTED/node_modules/dustjs-linkedin/lib/dust.js:177:75)
    at /Users/kevinsuttle/Code/REDACTED/node_modules/consolidate/lib/consolidate.js:100:5
    at fs.js:334:14
    at FSReqWrap.oncomplete (fs.js:95:15)
18 May 12:58:19 - [nodemon] app crashed - waiting for file changes before starting...
  • Should this be a Node-specific rule in ESLint? (I will ask over in their repo, too).

Forgive my newbness

Question: why the `bin` folder and `www` file?

Just curious why the app is structured that way? Most express apps/tutorials don't break the app up into two parts like this. Would love to get why this is a "best practice" as built by the generator. Thanks!

Npm start error

Hello, i am experiencing problem when i try to run my app. I install express-generator globally, then run 'express test_app', then 'npm install' in the test app folder and at the and 'npm start'. It is almost the same like this issue #31. The difference is that i am using Windows 7 and the error message is generated in the debug log. It looks like this:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart [email protected]
7 info start [email protected]
8 verbose unsafe-perm in lifecycle true
9 error Error: spawn ENOENT
9 error     at errnoException (child_process.js:1001:11)
9 error     at Process.ChildProcess._handle.onexit (child_process.js:792:34)
10 error If you need help, you may report this *entire* log,
10 error including the npm and node versions, at:
10 error     <http://github.com/npm/npm/issues>
11 error System Windows_NT 6.1.7601
12 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
13 error cwd C:\work\test_app
14 error node -v v0.10.30
15 error npm -v 1.4.21
16 error syscall spawn
17 error code ENOENT
18 error errno ENOENT
19 verbose exit [ 1, true ]

Reinstalled Node.js, but no effect. I have tried the same procedure on two other computers and there was no problem.

NPM Repository is old build.

I use npm install -g express-generator to install new generator for express 4.0.

But, the generator from NPM Repository isn't latest build.

So, the project created by express doesn't work on express 4.0.

Where is the logic?

I cannot seem to find the logic around the choices made within the basic setup when creating the scaffolding using the express-generator. As a NewB I find it very confusing to try and keep up with the structure of the scaffolding laid out.

For example, I based on the routing documentation I cannot seem to understand why you would generate a seperate module or where to handle the keys in this setup. Also, what is the order, is it all '/' checked in router then '/' user?

Also... the complicated npm script to for start, I would love to see a document explaining that choice.

I believe in best practices and really appreciate how easy it is to setup the scaffolding, I just wish I knew why this setup was chosen and how it fits into the express documentation.

Using express.js 4 with socket.io won't start

Surprisingly everything works well when doing node app.js instead of npm start.
Why is it?

I'm using express 4.2.0 and I've done:

express node6 --hogan --ejs 
cd node6
npm install
npm install socket.io

I went into the socket.io docs and I copied and pasted the code of the app.js file overwriting the one created by default. (which contains much more things)
After the pasting it would look like this:

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

server.listen(80);

app.get('/', function (req, res) {
  res.sendfile(__dirname + '/index.html');
});

io.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});

It is throwing errors when doing npm start.

Why is it?

This is the dpm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart [email protected]
7 info start [email protected]
8 verbose unsafe-perm in lifecycle true
9 info [email protected] Failed to exec start script
10 error [email protected] start: `node ./bin/www`
10 error Exit status 8
11 error Failed at the [email protected] start script.
11 error This is most likely a problem with the node6 package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error     node ./bin/www
11 error You can get their info via:
11 error     npm owner ls node6
11 error There is likely additional logging output above.
12 error System Windows_NT 6.1.7601
13 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error cwd C:\inetpub\wwwroot\node6
15 error node -v v0.10.29
16 error npm -v 1.4.14
17 error code ELIFECYCLE
18 verbose exit [ 1, true ]

After running node ./bin/www I get this error:

C:\inetpub\wwwroot\node6\bin\www:5
app.set('port', process.env.PORT || 3000);
    ^
TypeError: Object #<Object> has no method 'set'
    at Object.<anonymous> (C:\inetpub\wwwroot\node6\bin\www:5:5)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

The start entry of the package.json looks like this:

"start": "node ./bin/www"

Update to express 4.0

When will this be updated to express 4.0? I couldn't figure out a way to set up the new version because most of the repository still talks about 3.x.

add example generated directory.

What do you guys think about adding an example directory which is the generated directory from this generator?

This will serve as a reference to what is going on in the new versions of this generator. And i generally find it handy to know the structure before running the generator when i start a new project.

Follow existing style?

Shouldn't this codebase follow the same coding conventions as Express itself? E.g. 2 space indents?

Problem with generator and less

Hi, I have found a problem when I run the Express command with the --css less option, in the app.js:

app.use(require('less-middleware')({ src: path.join(__dirname, 'public') }));

It should be (options is an object):

app.use(require('less-middleware')(path.join(__dirname, 'public'), {options}));

Because the middleware take the first parameter as the source, and the second as the object with the options. I know because I got an error with path.js, and it was because the source wasn't a string.

Failing to install over an old `express` installation

I had an old installation of express (3.4.8), when I tried sudo npm install -g express-generator, I got this:

npm http GET https://registry.npmjs.org/express-generator
npm http 304 https://registry.npmjs.org/express-generator
npm ERR! error rolling back Error: Refusing to delete: /usr/local/bin/express not in /usr/local/lib/node_modules/express-generator
npm ERR! error rolling back     at clobberFail (/usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:57:12)
npm ERR! error rolling back     at next (/usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:43:14)
npm ERR! error rolling back     at /usr/local/lib/node_modules/npm/lib/utils/gently-rm.js:52:12
npm ERR! error rolling back     at Object.oncomplete (fs.js:107:15)
npm ERR! error rolling back  [email protected] { [Error: Refusing to delete: /usr/local/bin/express not in /usr/local/lib/node_modules/express-generator] code: 'EEXIST', path: '/usr/local/bin/express' }
npm ERR! Refusing to delete: /usr/local/bin/express not in /usr/local/lib/node_modules/express-generator
File exists: /usr/local/bin/express
Move it away, and try again.

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "express-generator"
npm ERR! cwd /Users/yaapa/hacklab
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/local/bin/express
npm ERR! code EEXIST
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/yaapa/hacklab/npm-debug.log
npm ERR! not ok code 0

I resolved it by manually deleting /usr/local/bin/express, but someone inexprienced may be left scratching their head. It would be great if this case is handled seamlessly.

Why am I getting this error after installing right out of the box?

Hello everyone.

So I've ran express -H -c "compass", ran without a hitch. npm install, also.

After I ran DEBUG=magisite ./bin/www the server seemed to be working, I got the "Express server running" message, but after just one (succesful, by the way) request, I got the following error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:988:11)
    at Process.ChildProcess._handle.onexit (child_process.js:779:34)

I haven't touched the code yet, this is clean from the installation.

Why is this happening? How can I even debug it?

How to start with nodemon

Since the new API, I can't start the app with node app.js or nodemon app.js
any suggestions? I don't understand how this works having to ./bin/www when the convention was to start the app or define how you start it in the package.json file. This no longer works? Is ./bin/www reading the app.js file?

needs tests

So, this module needs tests for sure. The tests should generate express apps with the command and run tests against the generated output, to be sure that the output actually functions.

You may need to require route after calling app.use(bodyParser)

if you do this :

[...]
var bodyParser = require('body-parser');

var routes = require('./routes/index');
var users = require('./routes/users');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', '{views}');

app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());{css}
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/users', users);
[...]

req.body is always empty if you submit form (POST) via the html way , because in your files settings each route, you call express.Router() before settings bodyparser.

The -h option to express is listed twice

The -h option was previously used for help. Now it is used for handlebars. I noticed this when doing express -h in a non-empty directory and getting prompted as follows:

destination is not empty, continue?

$ ./bin/express --help

Usage: express [options] [dir]

Options:

-h, --help          output usage information
-V, --version       output the version number
-e, --ejs           add ejs engine support (defaults to jade)
-h, --hbs           add handlebars engine support
-H, --hogan         add hogan.js engine support
-c, --css <engine>  add stylesheet <engine> support (less|stylus|compass) (defaults to plain css)
-f, --force         force on non-empty directory

Why "#!/usr/bin/env node" in www?

Why the default template of express 4 conatins "#!/usr/bin/env node" in the head of ./bin/www?

It couldn't be recognized by JSLint, etc,.

According to this ( expressjs/express#2123 ) post, @phoenixlzx pointed out that it should be treated as shell script.

But I think it doesn't cover all node platforms, such as Windows.
So why not keep "www" as "www.js" and use normal way to design the default template?

express-generator doesn't work

Hello,
I'd like to install express-generator by using this guide: http://expressjs.com/guide.html#executable

But I got error:

MM12-Danil:~ danil$ npm install -g express-generator
npm http GET https://registry.npmjs.org/express-generator
npm http 304 https://registry.npmjs.org/express-generator
npm http GET https://registry.npmjs.org/commander/1.3.2
npm http GET https://registry.npmjs.org/mkdirp/0.3.5
npm http 304 https://registry.npmjs.org/commander/1.3.2
npm http 304 https://registry.npmjs.org/mkdirp/0.3.5
npm http GET https://registry.npmjs.org/keypress
npm http 304 https://registry.npmjs.org/keypress
/usr/local/share/npm/bin/express -> /usr/local/share/npm/lib/node_modules/express-generator/bin/express
[email protected] /usr/local/share/npm/lib/node_modules/express-generator
โ”œโ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected] ([email protected])
MM12-Danil:~ danil$ express --help
-bash: express: command not found

So I decided to place bin to /usr/local/bin. Then I got another error:

MM12-Danil:node_js_demo danil$ express --help

module.js:340
    throw err;
          ^
Error: Cannot find module 'commander'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/local/bin/express:3:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

But it works when I installed it locally:

MM12-Danil:photo danil$ npm install express-generator express
npm http GET https://registry.npmjs.org/express-generator
.....
npm http 304 https://registry.npmjs.org/ms/0.6.2
[email protected] node_modules/express-generator
โ”œโ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected] ([email protected])

[email protected] node_modules/express
....
MM12-Danil:photo danil$ node_modules/express-generator/bin/express --help

  Usage: express [options] [dir]

  Options:

    -h, --help          output usage information
    -V, --version       output the version number
    -e, --ejs           add ejs engine support (defaults to jade)
    -H, --hogan         add hogan.js engine support
    -c, --css <engine>  add stylesheet <engine> support (less|stylus|compass) (defaults to plain css)
    -f, --force         force on non-empty directory

May be I did something wrong?

Next version release?

I'm really looking forward to the static website option in express generator. When is the next release?

less-middleware 2

the guys over at https://github.com/emberfeather/less.js-middleware have published version 2 of less-middleware which appears to not be compatible with express stable.

/Users/colby/Desktop/honeybird/node_modules/less-middleware/lib/middleware.js:50
    throw new Error('Please update your less-middleware usage: http://goo.gl/Y
          ^
Error: Please update your less-middleware usage: http://goo.gl/YnK8p0
    at module.exports.less.middleware (/Users/colby/Desktop/honeybird/node_modules/less-middleware/lib/middleware.js:50:11)
    at Object.<anonymous> (/Users/colby/Desktop/honeybird/app.js:21:35)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.