How to install ng2-completer with angular cli and webpack

4k Views Asked by At

I am trying to install ng2-completer. It work just fine when I run ng serve. However, my ng build --prod. I get following error

Module not found: Error: Can't resolve 'ng2-completer/ng2-completer.module' in 'folder_path/front/src/app'

My package-lock.json is as follows:

"ng2-completer": {
            "version": "2.0.6",
            "resolved": "https://registry.npmjs.org/ng2-completer/-/ng2-completer-2.0.6.tgz",
            "integrity": "sha1-IeW3sZft5jLYeDbMzxOSEWda2gs="
        },

I have tried importing package following ways:

import { Ng2CompleterModule } from '../../../../node_modules/ng2-completer/';

or

import { Ng2CompleterModule } from 'ng2-completer/';

I still get following error:

Module not found: Error: Can't resolve 'ng2-completer/ng2-completer.module' in '/User/test/Document/front/src/app'

any help is appreciated, thanks

3

There are 3 best solutions below

0
On

I had the same issue with the 2.0.6 version of ng2-completer. I don't know the reason, but it seems that the problem does not occur in the previous version. As a quick fix You can try downgrading it to the 1.x:

$ npm install ng2-completer@^1.0.0 --save

0
On

in angular 7.1.4 for using ngTable I had this Error and these follow commands worked for me.

npm i rxjs-compat --save

npm i ng2-completer --save

0
On

In angular 6 I was facing the same issue because ng2-completer library or file was not present in package.json file while which on being installed with the given command worked for me:

npm install ng2-completer --save