找不到模块:错误:无法解析Angular 6中的“./package”

前端之家收集整理的这篇文章主要介绍了找不到模块:错误:无法解析Angular 6中的“./package”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Angular 6和 scraperjs.

在我的组件文件中,使用了示例中给出的代码

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);
    });
  }

}

但它给出了错误

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'

解决方法

npm install

用于安装依赖包的命令.我认为依赖包没有正确安装.

猜你在找的Angularjs相关文章