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 8218865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:56:52+00:00 2026-06-07T12:56:52+00:00

This is driving me insane. I have a node app with express. It serves

  • 0

This is driving me insane.

I have a node app with express. It serves up a file called index.ejs.

All I wanna do is import a javascript file on this page (something like jquery). But it won’t pull it up, and I’m going nuts (as this should be simple).

On the server side I have this code in a file called app.js:

var express = require('express');
var app = express.createServer();
var hostName = (process.env.VCAP_APP_HOST || 'localhost');
app.listen( process.env.VCAP_APP_PORT ||  8000);
app.use(express.static(__dirname +  '/public/javascript/'));


//Create the view
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.set('view options', { layout: false });
app.get('/', function(req, res){
    res.render('index.ejs', {
              item : "document.write('Hello World');"
    });
});

In the ejs file, I have this:

<html>
        <script>
        <%= item %>
    </script>

<a href="">Link</a>
<script type="text/javascript" src="/javascript/jquery.js"></script>
</html>

I can see in the console that the script is not loaded (it shows an error). But for the life of me I can’t figure out why.

  • 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-07T12:56:54+00:00Added an answer on June 7, 2026 at 12:56 pm

    You need to add a static server to serve the other files you have under ‘/’. Currently your server is just responding to requests sent to ‘/’ (and views).

    Add this line to your express setup before app.get:

    // DOCUMENT_ROOT should point to the directory that contains your javascript directory.
    app.use(express.static(DOCUMENT_ROOT));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is driving me insane. I have a JS file that is: Ext.onReady(function(){ Ext.QuickTips.init();
This has been driving me insane all day and I think I have the
http://mehulkar.com/CD This is driving me insane. I have a fixed position header and a
I have this problem that is driving me insane. I have a project to
Okay, this thing is driving me insane, I have tried every way, I have
This is driving me completely insane. I have Disqus installed on my site and
I am a little OCD and this is driving me insane. I have been
This is driving me insane. All I want to do is pass a command
This is driving me farking insane. I'm trying to create a simple beginner app
This one is driving me absolutely insane, especially because I have a suspicion that

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.