I have an express.js block I want to refactor to be used in other parts of my webapp for example, I have function isPrime on my router file. I extract this block of code and put it in
./helpers/isPrime
module.exports = function isPrime(num) {
for(let i = 2 ; i < num ;i++){
if(num % i == 0){
return false;
}
}
return true;
}
when I added in route file I have this error Error: Cannot find module './helpers/isPrime' Require stack:
- /Users/auser/Documents/SandBox/AE_Technical_Challenge/routes/challengeRouter.js
- /Users/auser/Documents/SandBox/AE_Technical_Challenge/app.js
from express can 't find helper function module Error: Cannot find module './helpers/isPrime'?
No comments:
Post a Comment