Hey I'm trying to debug an error that's comming up with rendering a .jade page with node.js and ExpressJS.
The error is: Error: Failed to lookup view "/workspace/friends" in views directory "C:\Users\Utilizador\Documents\GitHub\QuantBull-Project\views".
So what are the reasons for occurring this error. I'm asking this because supposedly it should be working fine, at least it does with the other files...
I created a the following GET listener, located at controller/workspace.js to render the file:
/**
* GET /workspace/friends
*/
app.get('/workspace/friends', function (req, res) {
res.render('/workspace/friends', {
url: '/workspace'
});
});
and the file called friends.jade is located under views/workspace.
So I was wondering what can originate this error? Because this situation looks different compared to the other situations with the same error message I found on SO and others...
I think I figured out, problem is here.
use below
res.render('workspace/friends')
instead of
res.render('/workspace/friends')
When you say res.render('somefolder/file) so it searches in views/someolder/file. Because you are saying res.render('/somefolder/somefile) so it should be getting confused with /.
Related
I am facing some difficulties in apply the google drive api to my angular web app. I tried copying the code from https://developers.google.com/drive/api/v3/quickstart/js to my components html but I keep getting an error that says
zone-evergreen.js:171 Uncaught {error: "idpiframe_initialization_failed", details: "Not a valid origin for the client: http://localhosā¦itelist this origin for your project's client ID."}
However, when I put it as a normal index.html without it being in an angular app, the client id is valid. Is it possible that it is because of how angular renders the components, resulting in 'async defer' to be not working? If so, how do I resolve this.
I tried using #types/gapi and gapi-auth2 but I also encounter errors that the module cannot be found. I did many fixes like adding the compilerType but it still does not work so I am trying to use the default html. Thank you.
I am getting below error in console, everytime I am creating any project and I am not able to fix it.. I tried creating this file in different folders but still same error.. I have seen some of the threads which are opened for this Error on SCN but none of them worked for me. In my case app is not showing data.
I deployed the app on Git but it doesn't resolved. please help me.. This error I never got earlier.
create a "Component-changes.json" file in the same folder in that your index.html is located. inside your component-changes.json goes {}.
I try to use the Mailjet Wrapper for Node.js for my Ionic app.
Now I try to connect to the Mail by using following code :-
var connection = require(['node-mailjet'], function(mailjet){
mailjet.connect('api key', 'api secret');
});
But I'm getting this error:-
require.min.js:8 Uncaught Error: Script error for: node-mailjet
Does anybody know how to solve it? I already installed the require.js library.
Check out the link for the error you specified in the comment of this answer. Here you can find your solution
This occurs when there is a require('name') call, but the 'name' module has not been loaded yet.
May be something like the above statement is happening in your case i.e. node-mailjet is not loaded when you are trying to use it. (as per the error in the comment I have searched).
On my computer it's work well. After deploying on meteor.com I get error.
Creating collection look like this ( /lib/collections/messages.js )
Messages = new Meteor.Collection('messages');
On browser console after input
Messages.insert({})
I get
Uncaught ReferenceError: Messages is not defined
Its very likely you have a syntax error somewhere in your code.
If you check up your browser console the syntax error is visible.
On your localhost the files are not concatenated into one single js file, so if there is an error somewhere, then the issue isn't too bad & your app will run fine, mostly.
The thing is when your entire project is concatenated into one single js file then when there is an error higher up in your code, the downstream code will not execute. So the code at /lib/collections/messages.js does not run & this is why it is not defined.
The error is likely to be something like cannot read null of undefined or uncaught reference error or something like that. If you solve whatever is causing this error and redeploy your app.
I've upgraded my Sails.js app to 0.10.x and now when I point my browser at a non-existent route such as http://localhost:1337/notfound instead of my views/404.jade being served up I just get a bit of JSON
{
"status": 404
}
I built a default new sails app sails new dummy --template=jade just to compare and contrast with what I have in my existing app, and the only obvious difference I see is that in dummy/config/ there is a file called http.js
I've copied that file over to my app but it's made no difference.
I've also ensured that the tasks in dummy/tasks are identical to my own app's tasks.
In dummy/config/routes.js it says
Finally, if those don't match either, the default 404 handler is triggered.
See config/404.js to adjust your app's 404 logic.
Which is obviously out of date as 0.10.x apps use the api/responses mechanisms.
So I am at rather a loss as to how to get this to work.
I am using 0.10.0-rc8 (and I have confirmed that this is the same in my dummy app as well as my actual app)
Well I've fixed this but I have no idea why it was happening.
To fix it I created a new project as per the method described in my question, but with the same name as my existing project, then, file-by-file, I painstakingly moved across everything specific to my app, taking care to leave in place anything new generated by sails.
Once I'd done that I ran my tests - all passed - and then sails lift and tried it, and yay, everything worked and I got my 404 error page back.
I committed my changes and then carefully picked through a comparison of what had changed.
Alas nothing at all stands out, so, while I have solved my problem, I have no idea what the original cause was.
From the section in the migration guide on "Custom Responses":
In v0.10, you can now generate your own custom server responses. See
here to learn how. Like before, there are a few that we automatically
create for you. Instead of generating myApp/config/500.js and other
.js responses in the config directory, they are now generated in
myApp/api/responses/. To migrate, you will need to create a new v0.10
project and copy the myApp/api/responses directory into your existing
app. You will then modify the appropriate .js file to reflect any
customization you made in your response logic files (500.js,etc).
Basically, v0.10.x gives you more freedom in how things like res.notFound, res.serverError and even res.ok() (success response) work, but you need to copy over the new api/responses folder to migrate.
I had the same issue but was using 0.9.x. Probably a better solution but I outputted a view instead of JSON in all cases.
Update config/404.js to replace res.json() with res.view():
if (err) {
//return res.json(result, result.status); }
return res.view('404') // <-- output the 404 view instead
}
Then, just make sure in your routes.js file it will redirect the /404. Place the following at the bottom of your routes.js file:
'/*': {
view: '*'
},