A client would like to use an npm package to access our JavaScript file's functions instead of adding a script tag to their html. Is this possible? The only resource I've come across for creating an npm package is for NodeJS files ( https://docs.npmjs.com/creating-node-js-modules ).
This is possible but you cannot import the npm package and have it work in the browser without some sort of bundling system like webpack .
Alternatively, which is a bad idea, would be to ship your dist folder with node_modules
in it. This isn't recommended for a multitude of reasons, but it will work.
Following approach might be suitable for your client's requirement.
Refer this doc for using a package with.npmrc file: https://docs.github.com/en/packages/guides/configuring-npm-for-use-with-github-packages#installing-a-package ).
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.