Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

ENOENT: no such file or directory, open 'protos.json' #489

Closed
Etto91 opened this issue Dec 17, 2019 · 5 comments
Closed

ENOENT: no such file or directory, open 'protos.json' #489

Etto91 opened this issue Dec 17, 2019 · 5 comments
Assignees
Labels
api: speech Issues related to the googleapis/nodejs-speech API. needs more info This issue needs more information from the customer to proceed. 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. web

Comments

@Etto91
Copy link

Etto91 commented Dec 17, 2019

I'm trying to use the google cloud speech to text API.

I'm using the sample google code, and when I create the client object, I got this error.

{ 
   "errno":-2,
   "syscall":"open",
   "code":"ENOENT",
   "path":"protos.json",
   "stack":"Error: ENOENT: no such file or directory, open 'protos.json'\n    at Object.openSync (fs.js:440:3)\n    at Object.readFileSync (fs.js:342:35)\n    at fetch (transcript-server-js/node_modules/protobufjs/src/root.js:160:34)\n    at Root.load (/transcript-server-js/node_modules/protobufjs/src/root.js:194:13)\n    at Root.loadSync (/transcript-server-js/node_modules/protobufjs/src/root.js:235:17)\n    at Object.loadSync (/transcript-server-js/node_modules/@grpc/proto-loader/build/src/index.js:221:27)\n    at GrpcClient.loadFromProto /transcript-server-js/node_modules/google-gax/src/grpc.ts:165:40)\n    at GrpcClient.loadProto (/transcript-server-js/node_modules/google-gax/src/grpc.ts:199:17)\n    at new SpeechClient /transcript-server-js/lib/webpack:/src/v1/speech_client.ts:135:28)\n    at createText$ (/transcript-server-js/lib/webpack:/src/transcriptGenerator.js:50:18)"
}

this is the code

const speech = require('@google-cloud/speech');
const client = new speech.SpeechClient();

I got this error when I create the client.

I have added a log on the protobufjs/src/root.js file to see which files are fetched.

transcript-server-js/node_modules/protobufjs/google/protobuf/api.proto

transcript-server-js/node_modules/protobufjs/google/protobuf/google/protobuf/source_context.proto

transcript-server-js/node_modules/protobufjs/google/protobuf/descriptor.proto

transcript-server-js/node_modules/protobufjs/google/protobuf/source_context.proto

transcript-server-js/node_modules/protobufjs/google/protobuf/type.proto

protos.json

I tried to use storage api and they worked.

Where am I doing wrong?

can someone help me?

thanks

@bcoe bcoe added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. needs more info This issue needs more information from the customer to proceed. labels Dec 17, 2019
@bcoe
Copy link
Contributor

bcoe commented Dec 17, 2019

@Etto91 are you running this inside a Node.js application? Is there anything special about your environment, e.g., is it part of an angular application.

@Etto91
Copy link
Author

Etto91 commented Dec 17, 2019

Yes..I'm using fastify. I have used it inside a docker container after that I have tried on my local machine.
i'm using webpack with babel to compile the code.

@Etto91
Copy link
Author

Etto91 commented Dec 17, 2019

this is my webpack config

import path from 'path';
import fs from 'fs';
import webpack from 'webpack';
import NodemonPlugin from 'nodemon-webpack-plugin';

const outputServerPath = path.resolve('./lib/server.js');
const nodeModules = {};
fs.readdirSync('node_modules')
  .filter(x => ['.bin'].indexOf(x) === -1)
  .map(mod => {
    nodeModules[mod] = `commonjs ${mod}`;
    return mod;
  });

const serverFile = {
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  devtool: 'inline-source-map',
  entry: {
    server: './src/server.js'
  },
  output: {
    path: path.resolve(__dirname, 'lib'),
    filename: '[name].js',
    publicPath: '/dist/'
  },
  node: {
    __dirname: false,
    fs: 'empty'
  },
  target: 'node',
  externals: nodeModules,
  plugins: [
    new webpack.BannerPlugin({
      banner: 'require("source-map-support").install();',
      raw: true,
      entryOnly: false
    }),
    new webpack.DefinePlugin({
      NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
    }),
    ...(process.env.NODE_ENV !== 'production'
      ? [
          new NodemonPlugin({
            watch: outputServerPath,
            script: outputServerPath
          })
        ]
      : [])
  ],
  watchOptions: {
    ignored: /tests/
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'babel-loader'
      }
    ]
  }
};

module.exports = [serverFile];

@bcoe
Copy link
Contributor

bcoe commented Dec 17, 2019

@Etto91 if you're going to use @google-cloud/speech in the context of WebPack, there are a few additional steps. You can find a conversation related to getting our libraries up and running in a front-end context, with WebPack, here:

googleapis/google-cloud-node#2933

Let me know if this helps 👍

@bcoe bcoe closed this as completed Dec 17, 2019
@Etto91
Copy link
Author

Etto91 commented Dec 17, 2019

thanks @bcoe you saved my day

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: speech Issues related to the googleapis/nodejs-speech API. needs more info This issue needs more information from the customer to proceed. 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. web
Projects
None yet
Development

No branches or pull requests

4 participants