Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Error: Can't resolve './package' in Angular 6

I'm using Angular 6 and scraperjs.

and in my component file, used the code given in the example like

import { Component, OnInit } from '@angular/core';

import scraperjs from 'scraperjs';

@Component({
  selector: 'app-express',
  templateUrl: './express.component.html',
  styleUrls: ['./express.component.css']
})
export class ExpressComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    this.aliExpress();
  }

  aliExpress() {
    console.log('loaded ali express');

    scrapperjs.StaticScraper.create('https://news.ycombinator.com')
      .scrape(function ($) {
        return $('.title a').map(function () {
          return $(this).text();
        }).get();
      }).then(function (news) {
      console.log(news);
    });
  }

}

but it is giving error as

Failed to compile.

./node_modules/cheerio/index.js 
Module not found: Error: Can't resolve './package' in '/home/user/code/angular/ali-express/node_modules/cheerio'
like image 929
Anuj TBE Avatar asked Aug 13 '18 13:08

Anuj TBE


2 Answers

Run

npm install

command to install dependent packages. I think dependent packages are not properly installed.

like image 50
Vishal Pawar Avatar answered Oct 14 '22 14:10

Vishal Pawar


Remove the nodeModules from your solution folder structure and then try to install npm-install

like image 40
Raviteja V Avatar answered Oct 14 '22 12:10

Raviteja V