I am new to NodeJs and WebStorm. I have created a new "Node.Js Express App" using ejs template. I have created a Scripts folder inside my app root directory and trying load those files on my index.ejs file inside views folder.
When I run page in Chrome, it gives the following 404 error. For example, in my index.ejs body tag file, if I say:
<script type="text/javascript" src="Scripts/jquery.min.js"></script>
It will give following error:
"Failed to load resource: the server responded with a status of 404 (Not Found)"
I works fine in public folder by why it doesn't work if scripts and files are outside the public folder?
Related
Working on a weather application in node.js But when i tried to get the input value through document.getElementById to show weather about a specific location it is showing error
i have a file in my views folder where i provide JavaScript file using script tag but even then I am getting error.
error is given below:
GET http://localhost:3000/js/JavaScript.js net::ERR_ABORTED 404 (Not Found)
It is due to the fact that you are not serving a static files in your nodejs server. If you are using express server in your application you have to give the below code in main server js file
app.use(express.static('public')) here public means the folder where you have html, js folder, css folder
I'm attempting to implement push notifications in a reminder app I'm building. I am attempting to follow along to the way it is done in this demo project. To that end, I added a razor class library project entitled BlazorReminders.ComponentsLibrary to my BlazorReminders solution. Just as the BlazingPizza project did, I put the localStorage.js and pushNotifications.js files under the wwwroot folder of the ComponentsLibrary project. I then added a reference to the ComponentsLibrary in the client project and attempted to load the resources in the client's index.html file as follows:
<script src="_content/BlazorReminders.ComponentsLibrary/localStorage.js"></script>
<script src="_content/BlazorReminders.ComponentsLibrary/pushNotifications.js"></script>
This is the exact way they did it in the demo project, however for me it returned a "Failed to load resource: the server responded with a status of 404 ()".
A more detailed console message
GET https://localhost:44304/_content/BlazorReminders.ComponentsLibrary/pushNotifications.js net::ERR_ABORTED 404
I've also tried changing the src path to variations of "..\BlazorReminders\BlazorReminders.ComponentsLibrary\wwwroot\pushNotifications.js" to no avail; I got the same errors.
What could be causing the 404? Thanks
EDIT: Resolved
Thanks to agua from Mars for pointing out that I had forgotten to update the these package references in my ComponentsLibrary project file
//Version had to be changed to 3.2 preview
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.2.0-preview2.20160.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.2.0-preview2.20160.5" />
I recently deployed my website to GitHub Pages - https://max-stevenson.github.io/my-year-in-books/
I have a two local JavaScript libraries (jQuery and swiped-events) downloaded and within the following directory: src/public/js/lib.
In my index.html file at the root directory, I am linking to the two libraries like so:
<script type="text/javascript" src="/src/public/js/lib/jquery-3.4.1.min.js"></script>
<script src="/src/public/js/lib/swiped-events.js"></script>
But when I access the page on GitHub Pages I get the following errors:
GET https://max-stevenson.github.io/src/public/js/lib/jquery-3.4.1.min.js net::ERR_ABORTED 404 (Not Found)
GET https://max-stevenson.github.io/src/public/js/lib/swiped-events.js net::ERR_ABORTED 404 (Not Found)
When I run a local instance on my machine via a node express server and visit the site at localhost:3000, everything works great.
Can anyone please advise me where I'm going wrong and how to correctly reference my scripts so that they are loaded in GitHub Pages?
Try:
<script type="text/javascript" src="/my-year-in-books/scr/js/lib/jquery-3.4.1.min.js"></script
Or:
<script type="text/javascript" src="./scr/public/js/lib/jquery-3.4.1.min.js"></script
Running my ROR app with Puma locally. Getting the following error trying to load javascript/application.js
Failed to load resource: the server responded with a status of 404 (Not Found) javascript/application.js
Keep in mind this was a Ruby 1.9.3 app that I just updated the GEM file to 2.3.1
Does anything need to be changed when running a Rails app locally?
The source code shows
<script src="/javascripts/application.js"></script>
<link href="/bootstrap.min.css" rel="stylesheet">
<link href="/bootstrap-responsive.min.css" rel="stylesheet">
Locally, javascript files should be under app/assets/javascripts. They will be compressed, minified and copied into public during assets compilation (deployment)
Looks like there's no js files under /public/javascripts hence the 404 error you are getting.
It's also worth checking that you are starting the app in development mode. Otherwise, rails will look into public for js and css files.
See https://guides.rubyonrails.org/asset_pipeline.html#asset-organization for more details.
As I can see in my projects there is this kind of path
/assets/js/...
but maybe earlier was diffrent convetion.
Do you use static assets or dynamic on local ?
In my local development application the svg files show up just fine with the following code (The curly brackets embed Angular.js variables):
<img ng-src="img/servant_{{servant.personality}}.svg" draggable="false">
But when deployed on Heroku, the SVG files result in a 404:
Failed to load resource: the server responded with a status of 404 (Not Found)
The Angular variable is working on the Production site and the image addresses are accurate. So, that's not the problem.
Instead, I think my Node/Express application might not be able to serve SVG files. Perhaps it's a Heroku issue? FYI I'm using the MEAN stack.
Here is the configuration of my public folder:
//Setting the fav icon and static folder
app.use(express.static(config.root + '/public'));
The images are in
public/img
Any thoughts?
Ensure you have the correct mime-type configured to serve SVG files. Some servers simply respond with a 404 if the mime for the requested file type is not set.
image/svg+xml