Receiving `net::ERR_ABORTED ` only for included .js files - node.js

I used the express generator linked here to build a scaffold.
The 2nd thing I did was put two different 2ndary js files into place /public/js/useeasel.js and /public/js/libs/createjs.min.js
The 3rd thing I did was change the views to call those files like so
layout.hbs
<!DOCTYPE html>
<html>
<head>
<title>{{title}}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<script src='/js/lib/createjs.min.js'></script>
</head>
<body>
{{{body}}}
</body>
</html>
index.hbs
<h1>{{title}}</h1>
<p>Welcome to {{title}}</p>
<div onload="init();">
<canvas id="cid" width=2000 height=3000></canvas>
</div>
<script src="/js/useeasel.js"></script>
End result:
localhost/:6 GET http://localhost:3000/js/lib/createjs.min.js net::ERR_ABORTED
localhost/:16 GET http://localhost:3000/js/useeasel.js net::ERR_ABORTED
Bottom line is I did 3 things, edited nothing else, and received these error messages.
I tried jackin with app.js app.use(express.static(path.join(__dirname, 'public'))); but ultimately wound up just putting it back as nothing helped.
A weird thing tho. . . occasionally I'll get:
localhost/:16 GET http://localhost:3000/js/useeasel.js 404 (Not Found)
ONLY for that file. And sometimes, even, there's 2 entries for that file, one of each of the above errors.
The /stylesheets/style.css file works, and when I moved those 2 files to the /stylesheets/ dir (and changed the script call) they still didn't work, so I guess something is puking on .js files, but since I'm just running the express tutorials I've not the slightest.
What do I need to change here to make the js files work and the error messages go away?

Related

MathJax download cannot load in a local web page

I downloaded the latest copy of MathJax through Git, installed it somewhere, and wrote the following document:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Notes - Wenke's Patterns in Prehistory</title>
<script id="MathJax-script" async src="../../../../MathJax/e5/tex-chtml.js">
</script>
</head>
<body>
$ e^i $
</body>
</html>
When I try to run it in a browser the console prints the message Loading failed for the <script> with source “file:///home/username/underconstruction/MathJax/e5/tex-chtml.js”..
I believe the README.md file that comes with the download indicated that tex-chtml.js was supposed to be the file to link in the HTML document. I've seen elsewhere reference to a MathJax.js file but that was not included in my download.
You specify the location ("../..") of the file "tex-chtml.js" relative to the location of the HTML-page containing $e^i$. The file is likely not there as the warning message indicates. If you specify a path relative to the current HTML-page be also sure that the relative path is the same on your localhost and on the server.
A simple method for using MathJax is given on https://www.mathjax.org.
You do not need to download MathJax from anywhere. Just include the following lines in your HTML-file:
<head>
<script>
MathJax = {tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]}};
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax#3/es5/tex-mml-chtml.js"></script>
</head>

Grunt: How to correctly setup .html file for mocha testing?

I am new to grunt and tests and currently I have setup like this:
Grunt running tasks after which I have build folder where I have my compiled index.html and all his resources (css, js, images)
Now I want to run tests using grunt-mocha-phantomjs and it needs additions to my index.html like:
<link href="../node_modules/mocha/mocha.css" media="screen" rel="stylesheet" type="text/css" />
Inside head tag and:
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js" type="text/javascript" charset="utf-8"></script>
<script src="../node_modules/chai/chai.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
mocha.ui('bdd');
expect = chai.expect;
</script>
<script src="test.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
mocha.run();
</script>
Inside body tag.
I want to be able to open that modified index.html in web-browser too. (I have setup apache for it and example test works great both in grunt and web-browser)
So I am planning using task grunt-contrib-copy to copy all files from my build directory to test directory and add those lines to index.html and then launch mocha_phantomjs task.
Is this correct way to do it?
Which NpmTask can do it?
Not sure about "Is this correct way to do it?" part but I solved it.
I used grunt-html-build and its Removing parts feature.
Removing phantom's code for build folder, and keep it for testing folder.
It works great.

LESS, Dotless and Visualstudio

I started today with LESS. It looks awesome to work with and I will need it on my internship soon.
My less code:
#color: #4D926F;
body {
background-color: #color;
}
Not anything special.
My html:
<!Doctype HTML>
<html>
<head>
<title>#ViewBag.Title</title>
<link href="#Url.Content("~/Content/style.less")" type="stylesheet" rel="stylesheet/less" />
<script src="#Url.Content("~/Scripts/less-1.4.1.min.js")" type="text/javascript"></script>
</head>
<body>
#RenderBody()
</body>
</html>
The Less script file is downloaded from http://lesscss.org/
My file structure:
The result:
FileError: 'http://localhost:58123/Content/style.less' wasn't found (404)
in style.less
Index
When I install dotless via Package Manager everything works perfect.
My question is what do I need to runn it without Dotles? I dont have problems installing Dotless or using it. I just want to know whats the missing link why the LESS gives that error. Why do I get a 404 error when the file is there?
Dotless compiles the .less to .css. So you would need to add a reference to the resulting .css that Dotless compiles. Also you would want to remove this line from your code.
<link href="#Url.Content("~/Content/style.less")" type="stylesheet" rel="stylesheet/less" />

Getting TypeError: App.Router is undefined after building ember.js

Posting here as requested original post can be found here
Hello, I would like to build ember.js using Ubuntu 13.
I have cloned the official Github project, cd into the project and as described in the readme file I did:
bundle install
rake dist
no error is shown on screen and as a result I get a directory shown in the image
I would like to use ember and ember-data, so I include
ember.js
ember-data-deps.js
files in my test project.
The problem is that I am getting a TypeError: App.Router is undefined
I am using this at my client.js file to init ember
this.App = Ember.Application.create();
App.Router.map(function() {
this.route('contributors');
this.route('contributor', {path: '/contributors/:contributor_id'});
});
Am I doing something wrong in the build process?
Should I include some other js files in my project?
Thank you in advanced.
The TypeError: App.Router is undefined error is because ember.js is not loaded correctly or in the correct order.
To get ember-data (that is separate from ember.js) you have to clone this repo (https://github.com/emberjs/data) and follow the build instructions in the readme file, it's straight forward, and once you have the dist directory from the ember-data build process get the file ember-data.js development version or ember-data.min.js for production (well, production... ember-data is still considered unstable for production environments).
here is a simple ember project setup using ember-data:
index.html
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>ember app</title>
</head>
<body>
<script type="text/x-handlebars">
hello world!
</script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" src="http://builds.emberjs.com.s3.amazonaws.com/handlebars-1.0.0-rc.3.js"></script>
<script type="text/javascript" src="http://builds.emberjs.com.s3.amazonaws.com/ember-latest.js"></script>
<script type="text/javascript" src="http://builds.emberjs.com.s3.amazonaws.com/ember-data-latest.js"></script>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
app.js
var App = Ember.Application.create({
ready: function () {
console.log("app started...");
}
});
hope it helps

500 Error: ENOENT, open 'C:\Users\Gilbert\Documents\GitHub\maths4me\base.dust' with consolidate.js

I get this error when trying to set up inheritance in dust.js:
500 Error: ENOENT, open 'C:\Users\Gilbert\Documents\GitHub\maths4me\base.dust'
I have a file called index.html:
{>"base.dust"/}
{<title}Hi{/title}
Which calls base.dust:
<!DOCTYPE html>
<html>
<head>
<title>{+title}Maths 4 me{/title}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<h1>Hi</h1>
<p>Welcome to maths4me</p>
</body>
</html>
ENOENT means that file doesn't exist.
Check again that base.dust exists in provided location.
Dust partials look in the app root not the views folder, It took me some time to realise this. I was referencing a file in the wrong folder. My code should have been:
{>"/views/base.dust"/}
{<title}Hi{/title}
If you like me don't want to specify full paths to base templates and partials all the time, try out: klei-dust. (it's like consolidate but only for dustjs-linkedin)
In your scenario above you could just specify:
{>base/}
Instead of:
{>"views/base.dust"/}
...to get it to work.
Double check your names of your files. For me, I have seen this error Error: ENOENT, and I noticed that in one my main app.js, I wrote
app.get('/', function(req, res) {
res.sendfile('./views/plan.html');
});
when I in views folder,I renamed it to home.html, This error appears accordingly

Resources