Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical dependency: the request of a dependency is an expression | UnhandledPromiseRejectionWarning: Error: package.json does not exist #2284

Closed
kuncevic opened this issue Jan 11, 2020 · 5 comments

Comments

@kuncevic
Copy link

kuncevic commented Jan 11, 2020

After adding @angular/fire to the project the Angular universal prerender breaks. It shows this warnings at first:

WARNING in ./node_modules/grpc/src/grpc_extension.js 32:12-33
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js 20:22-48
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js 17:20-67
Critical dependency: the request of a dependency is an expression 

and then it breaks with this error:

Prerendering 1 route(s) to /Projects/firebase-issue/dist/firebase-issue/browser
(node:41122) UnhandledPromiseRejectionWarning: Error: package.json does not exist at /Projects/firebase-issue/dist/firebase-issue/package.json
    at Object.PsoT.exports.find (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:2061155)
    at Object.wPNL (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:3688583)
    at __webpack_require__ (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:295)
    at Object.XpdW (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:2342088)
    at __webpack_require__ (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:295)
    at Object.g1pB (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:3064029)
    at __webpack_require__ (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:295)
    at Object.Ou8q (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:2035913)
    at __webpack_require__ (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:295)
    at Object.BYZf (/Projects/firebase-issue/dist/firebase-issue/server/main.js:1:1191093)
(node:41122) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:41122) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Jan-12-2020 09-57-57

Version info

Angular:
9.0.0-rc.8
Firebase:
7.6.2
AngularFire:
5.3.0
Other (e.g. Ionic/Cordova, Node, browser, operating system):

"@nguniversal/express-engine": "9.0.0-rc.0",
"@angular/cli": "9.0.0-rc.8",
"@nguniversal/builders": "9.0.0-rc.0",

node v12.13.1

How to reproduce these conditions

  1. git clone https://github.com/kuncevic/firebase-issue
  2. yarn
  3. npm run prerender
@kuncevic kuncevic changed the title Critical dependency: the request of a dependency is an expression Critical dependency: the request of a dependency is an expression | UnhandledPromiseRejectionWarning Jan 11, 2020
@kuncevic kuncevic changed the title Critical dependency: the request of a dependency is an expression | UnhandledPromiseRejectionWarning Critical dependency: the request of a dependency is an expression | UnhandledPromiseRejectionWarning: Error: package.json does not exist Jan 11, 2020
@naingaungphyo
Copy link

I got the same error. As you already know, current workaround is setting grpc as externalDependencies in angular.json.

@jamesdaniels
Copy link
Member

Can you try 6.0.0-rc.0, see if that helps ngcc not explode?

@kuncevic
Copy link
Author

kuncevic commented Feb 4, 2020

@jamesdaniels Just tried with the latest

@angular/*: 9.0.0-rc.13
@angular/cli: 9.0.0-rc.12
@nguniversal/express-engine: 9.0.0-rc.1
@nguniversal/builders: 9.0.0-rc.1

Got new error like Error: No NgModule metadata found for 'class{}'. but then:

rm -rf yarn.lock node_modules
yarn
npm run prerender

And seems like its works now

@kuncevic
Copy link
Author

kuncevic commented Feb 4, 2020

Also checked with rc.14 looking good. Also tested npm run dev:ssr all works.

@hiepxanh
Copy link
Contributor

hiepxanh commented Feb 7, 2020

add

import 'firebase/firestore';
import 'firebase/analytics';
import 'firebase/auth';
import 'firebase/performance';

causing error now sir @jamesdaniels my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants