Troubleshooting problems when installing Angular and puppeteer

Recently, I started a fresh angular project with the goal of scraping data from a website and displaying it on my page. To achieve this, I thought of simply installing puppeteer via NPM after creating a new project. However, the compiler threw various errors post the puppeteer installation.

After setting up angular using ng new and adding puppeteer with NPM, running the code resulted in the following errors:

ERROR in node_modules/puppeteer/lib/types.d.ts(6,13): error TS1005: '=' expected.
node_modules/puppeteer/lib/types.d.ts(6,31): error TS1005: ';' expected.
node_modules/puppeteer/lib/types.d.ts(3460,46): error TS1005: ';' expected.
node_modules/puppeteer/lib/types.d.ts(3460,59): error TS1011: An element access expression should take an argument.

Specifically, the issues seem to revolve around these two lines of code in puppeteer:

import type { Readable } from 'stream';
//... and...
export declare type JSONArray = readonly Serializable[];

I am using nodejs version v16.13.2. Initially, I upgraded typescript to version 4.6.2 and also attempted upgrading @types/node due to previous errors. However, upgrading @types/node to the latest version only led to further complications.

ERROR in node_modules/@types/node/assert.d.ts(12,72): error TS1144: '{' or ';' expected.
...

So, for now, I have reverted back to version 12.0.2 to solely focus on the puppeteer-related issues.

Here's a glimpse of my current package.json:

{
  // Package.json details here
}

On a second attempt, running on a newer version of angular (13) and CLI produced a different set of errors:

// Errors related to modules not found or missing

In an effort to resolve these errors, I made adjustments to my package.json with:

"browser": {
   "fs": false,
   "path": false,
   "os": false
}

I also attempted installing path and stream via NPM but to no avail. While puppeteer integration worked fine in a small JavaScript project previously, it seems to be posing challenges when incorporated into an angular setup.

Answer №1

Puppeteer is a powerful node.js library that is not designed to be used directly in a web browser.

For more information, check out the documentation provided at this link, although it may be outdated.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to set a variable as true within a pipeline?

Could someone assist me with a coding issue I'm facing? If the id is null, I need variable x to be true. I am unable to use if and else statements within the pipe. Any guidance would be greatly appreciated. private x = false; private y = false; n ...

Take out a specific element from an array consisting of multiple objects

I have a specific array structure and I need to remove elements that match a certain criteria. Here is the initial array: const updatedUsersInfo = [ { alias: 'ba', userId: '0058V00000DYOqsQAH', username: '<a href=" ...

The correct way to type a generic React function component using TypeScript

When attempting to generalize the function component Element into a GenericElement component in TypeScript Playground, I encountered syntax issues that raised complaints from TypeScript. What is the correct method for typing a generic react function compo ...

Obtain the string value for the template variable

Trying to display a string literal if element.elementId is null or undefined. <div>{{String(element.elementId)}}</div> Encountering an error: TableBasicExample.html:6 ERROR TypeError: _co.String is not a function at Object.eval [as updat ...

Laravel Jetstream-inertia is presenting an error of TypeError: It is impossible to access properties of null, specifically the 'dataset'

Out of nowhere, this error suddenly popped up. I attempted to reinstall the npm packages without success. However, everything seems to work fine when I create a fresh project of jetstream-inertia with the same npm packages installed. Any assistance would ...

What are the benefits of incorporating a proxy.conf.json file into an Angular application?

Imagine we have a server running on http://localhost:8080/. Rather than configuring the back-end's base URL from environment.ts file, we can create a proxy.conf.json file with the code below: { "/api": { "target": "http://localhost:8080", ...

Encountered a problem while trying to install 'create-react-native-app' via npm

Encountering a problem during the installation process of the create-react-native-app application. npm install -g create-react-native-app npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! network request to https://registry.npmjs.org/create-react ...

Issue: The module 'xdl' cannot be located while executing the command "npm start" in React Native

Recently, I delved into learning React Native through an online Udemy course. Everything was going smoothly until a few days back when I encountered an error message after running the simple "npm start" command. Despite trying various solutions like reinst ...

Trigger a function upon a user's departure from a page or route in Angular 2

Is there a way to trigger a function only when the current route changes away from a specific component, such as when navigating away from "..../user/user-details"? I want this method to execute regardless of whether the route is changed through user inter ...

The ReferenceError occurs exclusively during the execution of tests

I keep encountering a dull stacktrace after executing my test. I've experimented with solutions like using fakeTimers, require('iconv-lite')..., etc, based on these queries: Encoding not recognized in jest.js ReferenceError: You are trying ...

TypeScript Generics: Property types do not match (the properties listed are missing)

In the code snippet below, I've defined an interface, type, and a function. interface ActionWithGeneric<T> { type: 'add' | 'remove'; data: T; } type StateWithGeneric<T> = Array<ActionWithGeneric<T>> ...

What are the recommended guidelines for where to place node-cron code?

Is it best practice to include node-cron functions in the server.js file or should they be placed inside designated server controller files? ...

Load Order Possibly Disrupted by Arrival of Barrel Imports

When attempting to unit test my component, I keep encountering errors related to my import statements: Error: Cannot resolve all parameters for 'MyComponent'(undefined, FormBuilder). TypeError: Cannot read property 'toString' of undef ...

Unable to execute function on Child Element

I am encountering an issue when trying to call a function on a child component. Whenever I try to invoke it by clicking, I always receive an error indicating that the function is undefined. Here is the code in my Parent component: import {MatTableCompone ...

Struggling to successfully deploy a Node.js application to both Heroku and OpenShift platform

Having trouble deploying my ExpressJS app to Heroku or OpenShift hosting. It works perfectly on my MacBook Pro, but crashes when I try to deploy it on the hosting platform. error Error: shasum check failed for /app/tmp/npm-403-gj-8PMyB/1387967953013-0.78 ...

The TypeScript error arises when an element implicitly contains an 'any' type due to the inability to use an expression of type 'any' to index a specific type

Encountering an Issue: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ foo: string; bar: string; }'.ts(7053) Within the following code snippet: const CATEGORY_COLORS ...

Tips for preventing event propagation while clicking on a swiper.js image next/prev button within a bootstrap card

I have integrated ngx-swiper-wrapper within a bootstrap card as shown below, with a routerlink at the top. When I click anywhere on the card, it successfully routes to the designated page. However, I am facing an issue where I want to prevent routing if a ...

Create a fresh Ionic 3 application utilizing Angular 4

After installing Ionic 3.6, which supports Angular 4.0.1, I encountered a problem. When creating a new project with the command ionic start newProject, it defaults to using Angular 5. This is evident from the package.json file below, showing angular-ionic ...

Error: node declarations are invalid: Syntax error encountered with the use of

Just starting out with nodejs and attempting to globally install typings in order to enable intellisense for a few modules by executing npm install -g typings Following this, I proceed to use: typings search tape resulting in the following error: C:& ...

Discover the process of translating words within app.routing.module.ts in Angular

Having some trouble with my Angular routing module and ngx-translate languages. I'm trying to retrieve words from the languages in this module, but the code I've attempted isn't working: import { NgModule } from '@angular/core'; im ...