Reputation: 57
So I started to learning Node.js recently so far the gatherings all are good but I came across the concept of setup with jsconfig.json
which largely helps to free the clutters made in mentioning the relative path and I decided to setup the same in my practicing node folder but unfortunately it doesn't work as expected , so this is my homecontroller.js file
"use strict"
const { request } = require('http');
const path=require('path');
const sbscrbrcntrllr=require('./subscribecontroller')
exports.getcntctfrm=(request,response)=>{
response.sendFile(path.join(__dirname,'../views/contact.html'))
}
and this is my jsconfig.json file
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@models/*":["models/"],
"@controllers/*":["controllers/"],
"@views/*":["views/"]
}
}
}
my folder will looks like this
-|
|
|- Controllers
| |-homecontroller.js
| |-subscribercontroller.js
|- views
| |-contact.html
|- index.js
|- jscongig.json
|- packages.json
my problem is that compiler is not reading properly and the error is something like this
Error: ENOENT: no such file or directory, stat '/home/scully86/organised-mongoose/controllers/@views/contact.html'
rather than particular with this I want a general work flow or syntax to work this out please suggest your tips
Upvotes: 0
Views: 935