pugjs / pug-loader

Pug loader module for Webpack
MIT License
425 stars 119 forks source link

'module' is not a known element error #120

Open kpambid opened 5 years ago

kpambid commented 5 years ago

I encountered this error whenever using pug in my app. I've surely installed ng-cli-pug-loader and it's dependencies(pug, pug-loader, apply-loader) though. Any ideas?

Screen Shot 2019-04-11 at 6 25 33 PM
kpambid commented 5 years ago

Upgrading to node 10.6 solved this problem.

kiseyob commented 5 years ago

I'm using node 10.15.3. But getting same error.

kpambid commented 5 years ago

I'm using node 10.15.3. But getting same error.

Try downgrading to 10.6 if you could.

David-van-der-Sluijs commented 5 years ago

try

npm clean-install

after upgrading you npm version to 10. It worked for me and fixed the issue.

cdll commented 4 years ago

same issue here with vue/cli on node@v10.15.3 which i got

<module class='export'>
  <!-- ANY TAGs... -->
</module>
alexprykhodko commented 4 years ago

I was getting the same error when using ng-cli-pug-loader. The issue is with the file ng-add-pug-loader.js produced by the ng CLI schematics. The file runs on npm postinstall and adds an extra rule to the webpack common.js file.

The solution is to replace the following line in ng-add-pug-loader.js right after running ng add ng-cli-pug-loader:

const pugRules = ' { test: /\.(pug|jade)$/, exclude: /\.(include|partial)\.(pug|jade)$/, use: [ { loader: "apply-loader" }, { loader: "pug-loader" } ] }, { test: /\.(include|partial)\.(pug|jade)$/, loader: "pug-loader" },';

with:

const pugRules = ' { test: /\\.(pug|jade)$/, exclude: /\\.(include|partial)\\.(pug|jade)$/, use: [ { loader: "apply-loader" }, { loader: "pug-loader" } ] }, { test: /\\.(include|partial)\\.(pug|jade)$/, loader: "pug-loader" },';

(note the additional escaping)

Version info:

Angular CLI: 9.1.1 Node: 13.12.0 Angular: 9.1.1

autaut03 commented 4 years ago

@alexprykhodko Thank you!

Just gonna add something: after replacing the config string, you have to make sure that this file: node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/common.js contains new, fixed config too, either by fixing it manually or reinstalling dependencies.