Cannot find name 'Lowercase'
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 8.0.0
- Platform / OS version: macOS Big Sur
- URLs (if applicable):
- Node.js version: v12.14.0
What steps will reproduce the problem?
- Install latest puppeteer version to an Angular universal project.
- import the puppeteer
import * as puppeteer from 'puppeteer';to the server.ts file - Build the project
What is the expected result?
There should not be any build errors
What happens instead?
getting below error in the console and there is no any type definition for Lowercase in the types.d.ts under the the puppeteer dependency in the node_modules folder.
chunk {0} main.js (main) 28 bytes [entry] [rendered]
ERROR in node_modules/puppeteer/lib/types.d.ts:24084:36 - error TS2304: Cannot find name 'Lowercase'.
24084 export declare type ResourceType = Lowercase<Protocol.Network.ResourceType>;
~~~~~~~~~
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pdf-generator-service-v2@0.0.0 build:ssr: `ng build --prod && ng run pdf-generator-service-v2:server:production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pdf-generator-service-v2@0.0.0 build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above
**source code**
import 'zone.js/dist/zone-node';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { join } from 'path';
import * as bodyParser from 'body-parser';
import { AppServerModule } from './src/main.server';
import { APP_BASE_HREF } from '@angular/common';
import { existsSync } from 'fs';
import * as puppeteer from 'puppeteer';
// The Express app is exported so that it can be used by serverless Functions.
export function app() {
const server = express();
const distFolder = join(process.cwd(), 'dist/browser');
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
server.engine('html', ngExpressEngine({
bootstrap: AppServerModule,
}));
server.set('view engine', 'html');
server.set('views', distFolder);
server.use(bodyParser.json({ limit: '5mb' }));
server.use(bodyParser.urlencoded({ extended: true, limit: '5mb' }));
// const browser = await puppeteer.launch({
// executablePath: '/usr/local/bin//chromium',
// headless: true,
// args: ['--no-sandbox']
// });
// Serve static files from /browser
server.get('*.*', express.static(distFolder, {
maxAge: '1y'
}));
// All regular routes use the Universal engine
server.get('*', (req, res) => {
console.log('aaaa', req.baseUrl);
res.render(indexHtml, { req, providers: [
{ provide: APP_BASE_HREF, useValue: req.baseUrl },
{ provide: 'body', useValue: req.body}]
});
});
return server;
}
function run() {
const port = process.env.PORT || 4000;
// Start up the Node server
const server = app();
server.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${port}`);
});
}
// Webpack will replace 'require' with '__webpack_require__'
// '__non_webpack_require__' is a proxy to Node 'require'
// The below code is to ensure that the server is run only when not requiring the bundle.
declare const __non_webpack_require__: NodeRequire;
const mainModule = __non_webpack_require__.main;
const moduleFilename = mainModule && mainModule.filename || '';
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
run();
}
export * from './src/main.server';
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:9
Top Results From Across the Web
Typings issues with version 8.0.0 - Cannot find name ... - GitHub
Lowercase <T> was introduced with TypeScript 4.1, so using any version newer then that should fix this problem. 6
Read more >export declare type ResourceType = Lowercase<Protocol ...
I'm working on a nodejs project to generate PDFs using Puppeteer in server side. In there I'm using typescript and current version of...
Read more >TypeScript error TS2304 cannot find name require - Edureka
The error that I'm getting is the "TS2304: Cannot find name 'require' " when I attempt to transpile a simple TypeScript Node.js page....
Read more >lowercase-keys - npm
Lowercase the keys of an object. Latest version: 3.0.0, last published: a year ago. Start using lowercase-keys in your project by running ...
Read more >TypeScript - String toLowerCase() - Tutorialspoint
TypeScript - String toLowerCase(), This method returns the calling string value converted to lowercase.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi all, this issue can be resolved by updating your typescript to any version above 4.1.
The Lowercase type was only added on 4.1.
I believe we can close this issue?
@rubenheymans Did not work for me even after removing node_modules. Is there any other specific version I could revert to?