I'm trying to create react typescript app with grpc,
my protoc version is: libprotoc 3.20.1
I'm running this command to compile a proto file:
protoc -I=. src/todo.proto --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:.
and getting this error:
protoc-gen-grpc-web: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--grpc-web_out: protoc-gen-grpc-web: Plugin failed with status code 1.
Related
I've written a simple .proto file
syntax = "proto3";
message Event {
optional string name = 1;
}
I've downloaded the protoc linux compiler (protoc-3.19.3-linux-x86_64.zip) and installed it in my local machine outside of the project's folder.
Then I installed the core runtime dependency with
$ npm i google-protobuf
My package.json shows:
"google-protobuf": "^3.19.3",
I then ran this line to generate the JS code from the .proto file
$ protoc --js_out=import_style=commonjs,binary:. protos/event.proto
It outputs some generated code that I can import with
const Schema = require("./protos/event_pb");
by inspecting Schema.Event I can see that my prop .name is in there, but I can't get any autocomplete going. Is there a way to achieve this?
Turns out there are some well-maintained npm packages that handle these things.
https://www.npmjs.com/package/protobufjs
or
https://www.npmjs.com/package/ts-proto
I try to execute v8 runtime environment from within c++ application to achive js support for my application. I successfully compile v8pp and now try to use the lib in my own console application. Currently I get a lot of unresolved symbol messages and do not get it what is the difference from working unit tests project within v8pp solution. Can someone point me to the right direction of what I am doing wrong here?
Build started...
1>------ Build started: Project: v8pp, Configuration: Debug Win32 ------
1>class.cpp
1>context.cpp
1>convert.cpp
1>json.cpp
1>throw_ex.cpp
1>version.cpp
1>Generating Code...
1>v8pp.vcxproj -> C:\git\v\v8pp\bin\Debug\v8pp.lib
2>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
2>ConsoleApplication1.obj : error LNK2019: unresolved external symbol "void __cdecl v8::api_internal::ToLocalEmpty(void)" (?ToLocalEmpty#api_internal#v8##YAXXZ) referenced in function "public: class v8::Local<class v8::Function> __thiscall v8::MaybeLocal<class v8::Function>::ToLocalChecked(void)" (?ToLocalChecked#?$MaybeLocal#VFunction#v8###v8##QAE?AV?$Local#VFunction#v8###2#XZ)
...
From what I can see I use same methods already used in unit tests.
I am trying to call a function in a python file from a js file, I got this to work through my console, but I am now trying to implement it in a mobile app using expo.
The way I had set this up is, I have the JS file for a certain screen in my app, this then calls a function in a separate JS file, which then calls the function in the python file.
I am using the child_process module to talk to python from JS.
And as I said, this was working before I tried to export the JS function to my screen file.
index.js
export function foo(process, sentence){
const spawn = require("child_process").spawn;
const process = spawn("python3", ["./python.py", sentence]);
...
}
screen.js
*other imports
import { foo } from "./filepath..."
...
But when I run npm start I get the following error:
Failed building JavaScript bundle.
While trying to resolve module `child_process` from file `/Users/mee/Documents/GitHub/project/app/screens/screen.js`, the package `/Users/mee/Documents/GitHub/project/node_modules/child_process/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/me/Documents/GitHub/project/node_modules/child_process/app/screens/screen.js`. Indeed, none of these files exist:
How can I fix this?
It won't work for few reasons
child_process is part of the node standard library, it's not available in other environments like react-native or browser
even if above was not true, there is no python3 executable on your phone
python.py file from your local directory wouldn't be even uploaded to the phone because bundler is only uploading one big js file with entire js code combined + assets, python.py is neither of those.
Only solution that make sense it to rewrite that code to javascript.
Technically it's not impossible, there might be a way to do that, by compiling python interpreter for mobile platform, or using some tool that translates python code into js, but it's not something that you should consider.
I installed the color-convert library via npm but the browser shows me an error message
Uncaught ReferenceError: require is not defined home.js:134
at HTMLButtonElement.<anonymous> (home.js:134)
at HTMLButtonElement.dispatch (jquery-3.4.0.js:5233)
at HTMLButtonElement.elemData.handle (jquery-3.4.0.js:5040)
JS
var convert = require('color-convert'); // this is line 134
alert(convert.hex.lab('DEADBF'));
I think there is a problem with paths?
require() isn't a function provided by your browser, and is more of a sign that this source code is a common JS module.
In order to use a common JS module, you first need to run your source through a program that bundles the source, sorta replacing each require('other_module') with the source of the other module, producing a single Javascript source file which can included in your frontend HTML.
Two examples of bundlers are browserify and webpack.
I have a react-native project written in JavaScript for which I'm trying to run the sonar-analysis.
I have a sonar server set-up for this and system where I'm trying to run the analysis has Sonar-scanner, npm and all other project dependencies installed.
However, When I run the sonar analysis on the react-native project I'm getting following error:
ERROR: Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
at org.sonar.java.JavaClasspath.init(JavaClasspath.java:59)
at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:281)
at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:141)
at org.sonar.java.JavaSquid.<init>(JavaSquid.java:83)
at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:83)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:111)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Had the same issue, and was wondering where did java files came in to a node project. Then by doing a file search I found several java classes in the node_modules folder. Was able to move forward by excluding them in the sonar properties file.
sonar.exclusions=test/**, node_modules/**
The error message is actually pretty clear:
Please provide compiled classes of your project with sonar.java.binaries property
Your project includes Java files, which cannot be analyzed without also providing their compiled .class files. You must either first compile (and feed the class file location into analysis) or exclude the .java files from analysis.