javascript - Can you use a npm package without using NodeJS - Stack Overflow

I found a library on github that I would like to use but the download instructions only mention using n

I found a library on github that I would like to use but the download instructions only mention using npm but I am not using a NodeJS project (just a basic html,css,javascript front-end with no back-end server). Am I still able to use that library or is it a lost cause? Is there another way to download it without using npm?

I found a library on github that I would like to use but the download instructions only mention using npm but I am not using a NodeJS project (just a basic html,css,javascript front-end with no back-end server). Am I still able to use that library or is it a lost cause? Is there another way to download it without using npm?

Share Improve this question asked Oct 17, 2016 at 12:58 Kevin ZhouKevin Zhou 1032 silver badges7 bronze badges 2
  • Which library is it? – JohnnyHK Commented Oct 17, 2016 at 13:09
  • github./SheetJS/js-xlsx – Kevin Zhou Commented Oct 17, 2016 at 17:48
Add a ment  | 

2 Answers 2

Reset to default 5

Is there another way to download it without using npm?

If it's on github, then you can checkout or fork the repository as you can with any other git repo.

Am I still able to use that library or is it a lost cause?

Whether or not the library will work without Node will depend on the library.

If it presents itself as a Node module, then you'll probably have to modify it (or find a patible module loader for browser-side JS).

If it depends on NodeJS features (such as the filesystem API) then you'll be out of luck (unless, for example, you polyfill them to work across HTTP)

If you use a build tool such as browserify, or webpack, you can author scripts that require node modules and the build tool will generate a script that includes all the necessary dependencies (assuming that the necessary dependencies are patible with client-side JavaScript environments).

Downloading dependencies would still be done via npm, but only for local development. Your server would only need the generated script.

Alternatively, if the script is on github or any other repo online you may be able to download it directly. Many modules are published using UMD, which would allow you to use the script using various inclusion methods.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743781661a4505915.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信