2
var typeOfUser = require('../js/type.js');  
var typeOfUser = require('./js/type.js');  
var typeOfUser = require('./type.js');

None of the above lines (written within a file named dashboardJS.js situated in folder named js) are working. require here is not working. The folder structure is:

Project_on_dairy/MDMS/js/type.js  
Project_on_dairy/MDMS/js/dashboardJS.js
8
  • 2
    The last should work, as well as require("type.js") Commented Dec 27, 2017 at 11:10
  • If it is written within a file named 'dashboardJS.js', then you should require it instead. Like this, require('./dashboardJS.js') Commented Dec 27, 2017 at 11:14
  • 1
    What is the error message you get for require('./type.js');? Commented Dec 27, 2017 at 11:16
  • 1
    What is the result of console.log(typeOfUser) after your require ? undefined ? Commented Dec 27, 2017 at 11:17
  • 2
    Define "not working". What did you expect to happen? What actually happened? Were there any error messages? Commented Dec 27, 2017 at 11:19

1 Answer 1

3

Maybe it will works if you try with something like this ?

var typeOfUser=require(__dirname + '/MDMS/js/type.js');

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.