How to publish a npm package with distribution files?
When you npm publish
, if you don't have an .npmignore
file, npm will use your .gitignore
file (in your case you excluded the dist
folder).
To solve your problem, create a .npmignore
file based on your .gitignore
file, without ignoring the dist folder.
Soure : https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package
Take a look at the "files" field of package.json file https://docs.npmjs.com/files/package.json#files
From the documentation:
The "files" field is an array of files to include in your project. If you name a folder in the array, then it will also include the files inside that folder. (Unless they would be ignored by another rule.)