Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Failed to lookup view "index" in views directory "/test/dist/app/views" #67

Closed
alexsuslov opened this issue Jan 27, 2014 · 12 comments

Comments

@alexsuslov
Copy link

OS X:

init

$> yo angular-fullstack --coffee --jade
  • all yes ;)
$> grunt serve:dist

$> cd dist
$> node server.js

connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Express server listening on port 3000 in development mode
finished populating things
finished populating users

Chrome http://localhost:3000

...
Error: Failed to lookup view "index" in views directory "/test/dist/app/views"
...

'app' - unnecessary

@DaftMonk
Copy link
Member

You need to run node in production mode for the distribution build.

E.g.

$ NODE_ENV=production node server.js

@ddad10
Copy link

ddad10 commented Mar 14, 2014

I get the same error running in production

@dearlordylord
Copy link

edited just realized that I forgot Grunt stuff. Sorry.

@adeperio
Copy link

Hey Im getting this issue too...can run dist locally but when I deploy to heroku i get this error

@jhurray
Copy link

jhurray commented Jul 8, 2014

same here.... any fix yet?

@tgienger
Copy link

For me I had to go into lib/config/express.js and change:

app.use(express.favicon(path.join(config.root, '/app', 'favicon.ico')));
app.use(express.static(path.join(config.root, '/app')));
app.set('views', config.root + '/app/views');

To:

app.use(express.favicon(path.join(config.root, '/', 'favicon.ico')));
app.use(express.static(path.join(config.root, '/')));
app.set('views', config.root + '/views');

@huangjihua
Copy link

Error: Failed to lookup view "index" in views directory "./views"
at EventEmitter.app.render (K:\项目\steven\GitHub\imooc-project2\imooc\node_modules\express\lib\application.js:519:17)
at ServerResponse.res.render (K:\项目\steven\GitHub\imooc-project2\imooc\node_modules\express\lib\response.js:904:7)
at app.get.res.render.title (K:\项目\steven\GitHub\imooc-project2\imooc\app.js:16:13)
at Layer.handle as handle_request
at next (K:\项目\steven\GitHub\imooc-project2\imooc\node_modules\express\lib\router\route.js:100:13)
at Route.dispatch (K:\项目\steven\GitHub\imooc-project2\imooc\node_modules\express\lib\router\route.js:81:3)
at Layer.handle as handle_request
at K:\项目\steven\GitHub\imooc-project2\imooc\node_modules\express\lib\router\index.js:235:24
at Function.proto.process_params (K:\项目\steven\GitHub\imooc-project2\imooc\node_modules\express\lib\router\index.js:313:12)
at K:\项目\steven\GitHub\imooc-project2\imooc\node_modules\express\lib\router\index.js:229:12

@tpflueger
Copy link

Was anything solved on this? I keep having the same error as above and wasn't able to fix it.

@karthikeyana
Copy link

use this code to solve the issue

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

@akhil-sharma25
Copy link

I fixed this error as I got it couple of times:
app.get('/', function(req, res){
res.render("/index");
});
never put "/" before rendering instead use :
app.get('/', function(req, res){
res.render("index");
});

@juanjosejaramillo
Copy link

Make sure that your folder is in the proper path. Accidentally I placed the folder inside my controllers folder and that's why I was getting that error.

@Yohei-Shiina
Copy link

I had the same issue and it turned out that I named views/index as index."js" but "jsx"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests