Cant use pug module with parcel?

31 Views Asked by At

I am trying to rendering the content with the pug template but I cant import the pug modules into this file, i'm using parcel to bundle all the js file also.

Here is the code:

import html from "../../views/reviews.pug";
import pug from 'pug';

const myReviewsBtn = document.querySelector('.my-reviews');
const settingsBtn = document.querySelector('.my-settings');

if (settingsBtn) {`your text`
    settingsBtn.addEventListener("click", changeActiveState(settingsBtn));
}

if (myReviewsBtn) {
    myReviewsBtn.addEventListener("click", async event => {
        event.preventDefault();
        changeActiveState(myReviewsBtn);
        const root = document.getElementById('root');
        const e = document.querySelector('.user-view__form-container');
        e.style.display = 'none';

        const { userId } = event.target.dataset;
        const { data } = await axios.get(`/api/users/${userId}/reviews`);
        ;
        console.log(data.data.data);
        const reviews = data.data.data;
        const content = pug.compileFile(html, {
            reviews
        });
        root.innerHTML = content;
    });
}

the error i got in the browser console is:

index.js:51  Uncaught TypeError: Unable to determine current node version
    at versionIncluded (index.js:51:9)
    at isCore (index.js:68:28)
    at 6v2Jh.3e9936faf252d157 (core.js:9:21)
    at newRequire (index.js:71:24)
    at localRequire (index.js:84:35)
    at 75Gdd.fab65eb61bd949bd (index.js:2:14)
    at newRequire (index.js:71:24)
    at localRequire (index.js:84:35)
    at 2zESx.92c7c5fc0e59f8 (run-filter.js:4:15)
    at newRequire (index.js:71:24)
0

There are 0 best solutions below