I'm start experiment with nodejs/coffeescript and the jade engine.

I can see from the examples that setup are around seems pretty standard.

 app = express.createServer().listen process.env.PORT

    app.configure ->
        app.set 'views', __dirname + '/views'
        app.set 'view engine', 'jade'
        app.set 'view options', layout: true
        app.use express.bodyParser()
        app.use express.static(__dirname + '/public')
        app.use app.router

    app.get '/ekmHoliCal/index', (req, res) ->
        res.render 'index'

My structure of directory is as follows:

-- ekmHoliCal
  -- public
     --javascripts 
          client.js
  -- views
       index.jade
       layout.jade

The index file contains the line: This is the index file

layout.jade file:

!!! 5
html(lang="en")
    head
        title Users
        script(type="text/javascript", src="http://code.jquery.com/jquery-1.6.4.js")
        script(type="text/javascript", src="/ekmholical/javascripts/client.js")
    body 
        div!= body 

When I navigate to /index I get served the index page as expected. However if I view source I see a link to jquery

<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.js">

and if I click on that link sure enough I see the source of the jquery file.

The index file also contains a link to my client.js :

<script type="text/javascript" src="/ekmholical/javascripts/simon.js"></script>

but when I click I get

Cannot GET /ekmholical/javascripts/client.js

Hi,

I'm not really sur but isn't there a "public" directory or this is something usual in JNode.
Also, you may add Javascript tag instead of Java tag.

If you're unable to access your JavaScript files from Node.js, here are some steps to troubleshoot:
Check file path: Ensure the path is correct and relative to your project structure.
Static file serving: If you’re using Express.js, use express.static() to serve static JavaScript files.
Permissions: Verify that your JavaScript files have the correct read permissions.
These steps should resolve the most common access issues.

commented: 6 years late. -4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.