Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
How to load Nodejs code into script file?

I am trying to load the code from my server file(code written in node.js,express.js) into my script file. When i console.log the identifier that i have used for importing nodejs code , nothing is shown in browser. And I don't even see there's an error

***nodejs code :*** 
const express = require("express");
const bodyParser = require("body-parser");
const ejs = require("ejs");


const app = express();

app.set("view engine", "ejs");

app.use(bodyParser.urlencoded({extended:true}));

app.use(express.static("public"));

app.get('/my-courses', (req, res) => {
    res.render('user-courses', {foo: 'hello'});
  });

// your courses section
const todaysDate = new Date();


  let userCourses = [
    {
     //some code
    },
    {
     //code
    }
  ];

  module.exports = userCourses;

 
app.listen("3000", ()=>{
    console.log("server running on 3000");
});

  ***[my script file code :][1]*** 
  const userCourses = require("/app");
  console.log(userCourses);
  
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!