简体   繁体   中英

How to use an npm module in angular

I've been trying to use a npm module called solc in AngularJs but I can't seem to succeed in anyway.

I know it's meant to be used with a Node application but I was wondering if there is a way to use it client side.

I've been trying to use Require.js and require every file included inside the git-repo but there are too many dependencies so I was wondering if there is another way.

I've been looking at browserify but that doesn't seems to do exactly what I need.

Does anyone have any idea?

You can use a npm package in browser applications if the package does not have any dependency on Node's built-in APIs. That's because Node APIs are available on server side and not on browser.

If you see here and here in the github repo of solc , you will see that it requires Node's built-in modules path and https . So it will not work in any browser application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM