Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:03:13+00:00 2026-06-18T15:03:13+00:00

I am trying to serve an html page with a linked js script using

  • 0

I am trying to serve an html page with a linked js script using node.js and express.
This is the server that provide the page:

var express = require("express");
var app2 = express();
app2.get('/', function(req, res) {
   res.sendfile('./index.html');
});
app2.listen(process.env.VCAP_APP_PORT || 3000);

and this is the page:

<!DOCTYPE html>
<html>
<head>
    <title>Demo</title>
</head>
<body>
    <h1>Demo</h1>
    <script src="/js/socket.io.js"></script>
    <script src="/js/codice.js"></script>
</body>

As you can see I have two js scripts in my js folder but they are not loaded when I launch the page. What can I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:03:14+00:00Added an answer on June 18, 2026 at 3:03 pm

    What you would normally do is place any public resources (JavaScript files, CSS files, images etc) in a directory (Express names it public by default) and then use the express.static middleware in your app.configure call:

    app.configure(function () {
        // Various other middleware functions...
        app.use(express.static(path.join(__dirname, "public")));
    });
    

    This effectively runs a static file server which will return any file inside the public directory. Currently, your browser is making a request for your JS files, but the Express server doesn’t know what to do with them. They will eventually time out.

    If you generate the initial state of your app with the global express executable (available if you installed Express via npm globally), it will set most of this up for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to serve an html page that includes unicode text using django and
I'm trying to build a blog/messageboard that uses static HTML files to serve content.
i am trying to use this code: <%= File.ReadAllText(Server.MapPath(Members/newsletters/welcome.html))%> which works great but now
I'm trying to serve a dynamically generated html page with Erlang Cowboy, but it
I'm trying to display a page of html using bottle (the python web framework).
I am trying to get an HTML page source content from this site: http://207.200.96.231:8008
I'm trying to serve a gzipped version of a text/html page in Django, but
I'm trying to use express to serve static pages with express that communicate with
My question is this, if I have a page say index.HTML that has some
I'm trying to load an html page from a server the page contains a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.