3

For reference, the repo is https://github.com/microsoftly/luis-response-builder.

The node module files are generated with tsc and output to the dist folder. I have a prepublishOnly step that removes the dist folder, runs tsc, then runs the test against the transpiled js. The tests pass when I publish just fine.

The problem is, when I install the project anywhere else, the dist folder contains only the file with the path dist/src/index.js.

I cannot for the life of me figure out why the file is missing when installed but not when published.

2 Answers2

6

Quoting from npm-publish Documentation:

All files in the package directory are included if no local .gitignore or .npmignore file exists. If both files exist and a file is ignored by .gitignore but not by .npmignore then it will be included.

Your repository's .gitignore file contains the following:

node_modules
dist
*.env
yarn-error.log

Since dist is being ignored, it's not committed with npm publish, as per the documentation.

Patrick Roberts
  • 49,224
  • 10
  • 102
  • 153
3

Check out the package.json documentation about files.

Since you haven't included the files key, it will only include the file specified in main (along with some other default files).

The files value is an array so you can include multiple files and/or folders.

eg:

files: [
  "dist",
  "config/somefile.js"
]
trs
  • 339
  • 3
  • 8
  • You are right, I seem to have missed his/her `.gitignore` file. Thanks for clarifying. – trs Jul 26 '17 at 16:43