1

I'm building an Ionic app in Angular/Typescript.

I'm using a library called emojiRegex and I'm a little uncertain how to use it.

I'm importing it like this:

import { emojiRegex } from 'emoji-regex';

and then according to the docs you have to require it?

So I'm doing:

let emojiRegex = require('emoji-regex');
if(emojiRegex().test(this.emoji)) {

which works, but I get a typescript error I'd like to remove..

I read you need to add to your `tsconfig.json:

"types": [
  "node"
],

and then run npm install @types/node --save-dev which I did, but it didn't work for me. I just get another error that states:

[10:39:24] typescript error Cannot find type definition file for 'node'.

So any ideas how I can do this? I feel like I'm missing something pretty simple.. Thanks!

4
  • seen this?? stackoverflow.com/questions/43104114/… Commented Jun 8, 2018 at 15:04
  • @AshishRanjan that did not work :/ i get that Cannot find type definition file for 'node' error Commented Jun 8, 2018 at 15:07
  • try giving types as: "types": [] Commented Jun 8, 2018 at 15:10
  • @AshishRanjan that removed the node error but it still doesn't allow require Commented Jun 8, 2018 at 15:15

1 Answer 1

5

You should be able to import it as a const like so:

import * as emojiRegex from 'emoji-regex';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.