Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing file extensions are breaking webpack-dev-middleware #197

Closed
scott-cornwell opened this issue Mar 15, 2018 · 5 comments
Closed

Missing file extensions are breaking webpack-dev-middleware #197

scott-cornwell opened this issue Mar 15, 2018 · 5 comments

Comments

@scott-cornwell
Copy link

Doing hot reload of node server that runs webpack-dev-middleware. It depends on mime and in the index.js of mime it imports some json files in types with no extension. If I add the .json extension it works. Can these be added please?

@scott-cornwell
Copy link
Author

Nevermind, it was my fault, I just needed to add .json to my webpack resolve.extensions.

@marlon360
Copy link
Contributor

When using this module with an Angular CLI project, I got this error:

ERROR in ./node_modules/mime/index.js
Module not found: Error: Can't resolve './types/other' in '/www/mime-type-ng/node_modules/mime'
ERROR in ./node_modules/mime/index.js
Module not found: Error: Can't resolve './types/standard' in '/www/mime-type-ng/node_modules/mime'

In Angular CLI project you cannot edit the webpack configuration to resolve .json extensions.
Is it possible to change this line:
module.exports = new Mime(require('./types/standard'), require('./types/other'));
to this:
module.exports = new Mime(require('./types/standard.json'), require('./types/other.json'));

@broofa
Copy link
Owner

broofa commented May 22, 2018

@marlon360, then that's an issue with Angular or your Angular config.

The CommonJS spec explicitly says module identifiers should not include an extension. And in Node.js the json extension is optional, just like the js extension.

@nevercast
Copy link

Ah, thanks @broofa, for a moment I thought this was an issue with mime. I've fixed my webpack 👍

@marlon360
Copy link
Contributor

If you don't want to or not able to edit the Webpack configuration, you can install my wrapper: https://github.com/marlon360/mime-wrapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants