Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: ENOENT: no such file or directory, open 'google/protobuf/api.proto'

I want to integrate angular universal into my project and I use AngularFire library. But when I test my app locally by running npm run build && npm run serve:ssr.

I have this error

  webpack:///./dist/server/main.js?:95613
                throw err;
                ^

    Error: ENOENT: no such file or directory, open 'google/protobuf/api.proto'
        at Object.openSync (fs.js:440:3)
        at Object.readFileSync (fs.js:342:35)
        at fetch (webpack:///./dist/server/main.js?:95679:34)
        at Root.load (webpack:///./dist/server/main.js?:95713:13)
        at Root.loadSync (webpack:///./dist/server/main.js?:95754:17)
        at Object.loadSync (webpack:///./dist/server/main.js?:133270:17)
        at Object.8ZNE (webpack:///./dist/server/main.js?:98662:37)
        at __webpack_require__ (webpack:///./dist/server/main.js?:20:30)
        at Object.BYZf (webpack:///./dist/server/main.js?:104679:19)
        at __webpack_require__ (webpack:///./dist/server/main.js?:20:30) {
      errno: -2,
      syscall: 'open',
      code: 'ENOENT',

  path: 'google/protobuf/api.proto'
like image 298
Dsam Avatar asked Apr 15 '20 09:04

Dsam


2 Answers

I got this from another post, but it did help me out to fix that error (I had been looking for fixes for a while now).

Hope it works for you

angular.json

"server": {
  "builder": "@angular-devkit/build-angular:server",
    "options": {
      "outputPath": "dist/TeacherKellyUKA/server",
      "main": "server.ts",
      "tsConfig": "tsconfig.server.json",
      "externalDependencies": ["@firebase/firestore"]
  },
like image 64
jessemoon0 Avatar answered Oct 19 '22 11:10

jessemoon0


This is an issue with AngularFirestoreModule. I have updated below line in package.json and it is working fine. I am using angular version 8.

"bundleDependencies all" to "bundleDependencies none"

"build:client-and-server-bundles": "ng build --prod && ng run web:server:production --bundleDependencies none"
like image 21
Ajay Nikam Avatar answered Oct 19 '22 12:10

Ajay Nikam