最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Module "util" has been externalized for browser compatibility. Cannot access "util.promi

programmeradmin0浏览0评论

I am trying to scrape LinkedIn profile using this library: /@n-h-n/linkedin-profile-scraper. This is my code:

<script>
import { LinkedInProfileScraper } from '@matidiaz/linkedin-profile-scraper';
    import { onMount } from 'svelte';
    import { session } from '$app/stores';

    onMount(async () => {
        const token = session?.provider_token;
    console.log(token);
        const scraper = new LinkedInProfileScraper({
            sessionCookieValue: token,
            keepAlive: false
        });

        // Prepare the scraper
        // Loading it in memory
        await scraper.setup();

        const result = await scraper.run('/');

        console.log(result);
    });
</script>

I am using sveltekit to get the information, can someone point out how to solve this problem, I am not finding much information online.

I am trying to scrape LinkedIn profile using this library: https://www.npmjs.com/package/@n-h-n/linkedin-profile-scraper. This is my code:

<script>
import { LinkedInProfileScraper } from '@matidiaz/linkedin-profile-scraper';
    import { onMount } from 'svelte';
    import { session } from '$app/stores';

    onMount(async () => {
        const token = session?.provider_token;
    console.log(token);
        const scraper = new LinkedInProfileScraper({
            sessionCookieValue: token,
            keepAlive: false
        });

        // Prepare the scraper
        // Loading it in memory
        await scraper.setup();

        const result = await scraper.run('https://www.linkedin.com/in/jvandenaardweg/');

        console.log(result);
    });
</script>

I am using sveltekit to get the information, can someone point out how to solve this problem, I am not finding much information online.

Share Improve this question edited Nov 28, 2023 at 19:21 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 12, 2022 at 14:07 equiequi 1641 gold badge1 silver badge11 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 14

Hi what worked for me was to fix the vite.config.ts to add resolve.alias options like this:

resolve: {  
    alias: {
        process: "process/browser",
        stream: "stream-browserify",
        zlib: "browserify-zlib",    
        util: "util/",
        '@': path.resolve(__dirname, './src'),
    }
}

where we actually resolve the alias of util and add to it 'util/'

npm i util,

however this lib continues giving errors so I removed it.

https://www.npmjs.com/package/@browsery/util

npm i @browsery/util -s

Vite config alias add:

util: "@browsery/util"

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论