加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 18:07:03 所属栏目:安全 来源:网络整理
导读:我正在使用Angular 6和 scraperjs. 在我的组件文件中,使用了示例中给出的代码 import { Component,OnInit } from '@angular/core';import scraperjs from 'scraperjs';@Component({ selector: 'app-express',templateUrl: './express.component.html',styleU
我正在使用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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读