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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:05:46+00:00 2026-06-15T12:05:46+00:00

I am unable to call my script.js file from inside jade though javascript renders

  • 0

I am unable to call my script.js file from inside jade though javascript renders perfectly fine if inserted inline. This is my first attempt, so the js file is simply an alert:

alert("javascript works");

I’m inclined to believe that I am improperly calling the script. Currently layout.jade looks like:

doctype 5
html
  head
    title= "LeafPress - Hot off the Presses"
    link(rel='stylesheet', href='/stylesheets/style.css')
  block scripts
    script(type='text/javascript', src='/javascripts/script.js')
  body
    block content

I’ve tried a number of permutations of the script path (../public/javascripts/script.js; /public/javascripts/script.js; public/javascripts/script.js; javascripts/script.js; script.js), as well as trying placing the script directly in the root and ‘views’ dir.

app.js:

/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes/index')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path');

var app = express();

app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.cookieParser('your secret here'));
  app.use(express.session());
  app.use(app.router);
  app.use(require('stylus').middleware(__dirname + '/public'));
  app.use(express.static(path.join(__dirname, 'public')));
});

app.configure('development', function(){
  app.use(express.errorHandler());
});

app.get('/', routes.index);
app.get('/permalink', routes.permalink);
app.get('/users', user.list);

http.createServer(app).listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));
});

index.js:

/*
 * GET home page.
 */

exports.index = function(req, res){
  res.render('index', { title: 'Express' });
};

exports.permalink = function(req, res) {
  res.render('permalink', { title: 'Comments page' });
};

My relevant file hierarchy looks like:

- public
  - javascripts
    - script.js
- views
  - index.jade
  - layout.jade
- routes
  - index.js

app.js

This seemed relevant, but didn’t fix the problem: static javascript not rendering in jade (with express/node.js)

  • 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-15T12:05:47+00:00Added an answer on June 15, 2026 at 12:05 pm

    Try removing this line entirely app.use(app.router);. Manually changing the location of the router in the express middleware stack is usually going to yield undesired behavior. Don’t do it unless you are truly certain you know exactly why you are doing it and what you expect to happen. What the express logger’s output for the notorious cannot GET /javascripts/script.js, which will point directly at middleware/routing misconfiguration.

    I’m guessing your markdown syntax is your question is just busted, but make sure the script.js file is inside the javascripts directory, not a sibling of it.

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

Sidebar

Related Questions

I am unable to call a javascript function as it says Object Expected. I
I have this piece of code that works fine in the webpage: <script src=http://code.jquery.com/jquery-1.7.1.min.js></script>
I'm have some difficulties here, I am unable to successfully call a method which
Just a quick question. Say a call a method like so mysql_pconnect(server,tator_w,password) or die(Unable
Im unable to start new project in a virtualenv. This is what i did
Error: Unable to read data from the transport connection: A blocking operation was interrupted
I'm unable to execute the following prepared statement , PREPARE stmt FROM 'SELECT sb.id,sb.category,sb.make,sb.name,sb.pic,rs.slot
I am getting a Unable to load the requested file: default.php error in codeigniter
I have a small script we're using to read in a CSV file containing
I am trying to call TF get command via Team Build script. I am

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.