https://github.com/marlon360/mime-wrapper
An Angular v6+ wrapper for the node-mime package.
https://github.com/marlon360/mime-wrapper
Last synced: 9 months ago
JSON representation
An Angular v6+ wrapper for the node-mime package.
- Host: GitHub
- URL: https://github.com/marlon360/mime-wrapper
- Owner: marlon360
- License: mit
- Created: 2018-06-02T20:15:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-18T10:10:58.000Z (almost 6 years ago)
- Last Synced: 2024-05-02T06:11:51.768Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 5
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## Information
Since version 2.4.3 of the `mime` package, this wrapper is not needed anymore. Now you can use it directly with Angular. See [this issue](https://github.com/broofa/node-mime/issues/208).
# mime-wrapper
This is a wrapper for the [node-mime](https://github.com/broofa/node-mime) module by [broofa](https://github.com/broofa).
It allows you to use node-mime with Angular-CLI projects.
## Install
```sh
$ npm install mime-wrapper mime
```
## Usage
In Angular:
```js
import { mimeTypes } from "mime-wrapper";
mimeTypes.getType("file.png");
mimeTypes.getExtension("text/plain");
```
## Why
If you use the module node-mime in Angular-CLI Projects version 6, you will see 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 projects you cannot modify the webpack config to resolve other extensions than ".js" and ".ts". This package fixes this, without the need of ```ng eject```.
## Thanks
Thanks to [pfeigl](https://github.com/pfeigl).
([issue](https://github.com/jshttp/mime-types/issues/50#issuecomment-390932678))