grpc-web
grpc-web copied to clipboard
NPM install for proto-gen-grpc-web: notarget No matching version found for [email protected].
I am trying to install proto-gen-grpc-web by using this command
npm i [email protected]
But it doesn't update to 1.3.0 and stays onto 1.2.1
npm ERR! code ETARGET npm ERR! notarget No matching version found for [email protected]. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist.
I just checked the npm registry, it still shows version 1.2.1 ---- 1.3.0 hasn't been released there yet.
Can someone help?
Related issue https://github.com/hronro/protoc-gen-grpc-web-npm/issues/8
I don't know why, but grpc-web do not provide the ability to install the utility for code generation via npm. For fast solution you can to fork https://github.com/hronro/protoc-gen-grpc-web-npm and change version in post-install script.
Download cli tool with postinstall npm hook in your project, for example:
const path = require("path");
const VERSION = "1.3.0";
const DL_PREFIX = "https://github.com/grpc/grpc-web/releases/download/";
const EXT = process.platform == "win32" ? ".exe" : "";
const PLATFORM_NAME = process.platform === "win32" ? "windows" : process.platform;
const PLUGIN_NAME = "protoc-gen-grpc-web-" + PLATFORM_NAME + VERSION + EXT;
const PLUGIN_DIR = path.resolve(__dirname, "bin");
const PLUGIN = path.resolve(PLUGIN_DIR, PLUGIN_NAME);
module.exports = { EXT, PLUGIN_DIR, PLATFORM_NAME, PLUGIN_NAME, PLUGIN, DL_PREFIX, VERSION };
// Forked from https://github.com/hronro/protoc-gen-grpc-web-npm
// Grpc-web do not provide own npm package for code generation utility
// So we need install it from github :(
const fs = require("fs-extra");
const download = require("download");
const { DL_PREFIX, PLUGIN_DIR, VERSION, PLUGIN, EXT, PLATFORM_NAME } = require("./grpc-web-gen");
async function downloadPackage() {
if (process.arch !== "x64") {
throw new Error(`Unsupported arch: only support x86_64, but you're using ${process.arch}`);
}
await fs.ensureDir(PLUGIN_DIR);
const execFilename = `protoc-gen-grpc-web-${VERSION}-${PLATFORM_NAME}-x86_64${EXT}`;
const downloadUrl = DL_PREFIX + VERSION + "/" + execFilename;
console.log("Downloading", downloadUrl);
const buffer = await download(downloadUrl).catch((err) => {
console.error(err.message);
process.exit(1);
});
await fs.writeFile(PLUGIN, buffer);
await fs.chmod(PLUGIN, "0755");
}
downloadPackage().catch((err) => {
throw err;
});
Use it for child_process.exec
`grpc_tools_node_protoc --plugin=protoc-gen-grpc-web=${PLUGIN}`,
@AsmaRahimAliJafri Thanks for the report and sorry for the trouble!
But sorry we don't own the protoc-gen-grpc-web npm package nor do we currently maintain a npm package that deliveries the protoc-gen-grpc-web binary.
@AZbang's comments sounds like a good workaround. Would that be something that works for you?
Going forward, if there continues to be a strong need, we could consider adopting something like that given there's a way to make it work robustly on ALL platforms. But nothing planned at this moment yet :)