Install NuGet package in node.js project

1k Views Asked by At

I have a node.js project that executes a certain dll using edge.js package.

Is there a way to install a NuGet package in my node.js project and run it as I do with the dll?

2

There are 2 best solutions below

0
On

Is there a way to install a NuGet package in my node.js project and run it as I do with the dll ?

No there isn't. NuGet is a .NET package manager and npm is a node.js package manager. They work in their own respective areas.

What you're actually looking for is a script solution. Write a shellscript which takes care of installing the respective packages of NuGet and npm. Assuming your env variables and paths are correct you'll be able to call the required package from edge.js correctly.

0
On

First the generic part:

Usually, such kinds of things are managed with postinstall hook (and it's nice to have this hook right in the package itself, so you can install any binary dependencies). However, if it's not defined in the package - you always can add it by yourself (on your project level) - for example, put some cmd/sh/js script, and do whatever you want to do after installing dependencies

More specific part:

What system do you use? I'm asking cause as far as I see here the package already has some built-in binary installation. And that win32 (as per documentation) should be the value for any Windows-based system. I would invest 5-10 minutes to debug that script (at least with console.logs) to check why it doesn't work

The moment with is suspicious for me - (first check this article as an example) is that in the package hook is not inside postinstall. But here again - install is a valid hook (there are 3 in line - preinstall, install, postinstall). So here you can try cd node_modules/edge-js && npm run install just to be sure if it's run or not