We have a self-hosted GitLab (15.5.4) and I've configured everything we needed for publishing npm packages. A CI/CD pipeline that properly creates the entry in the Package Registry.
The problem is that when I pull the package [npm i @scope/lib
] (It doesn't change if I cast the auth token in the package.json or I pass through an environment variable as suggested in the documentation) the unwanted result is that the @scope/lib
doesn't have the dist/
folder in it!! [node_module/@scope/lib/
].
If I browse to the Package Registry and manually download the .tgz
file I can see that the dist/
folder is present.
I've played around a bit with the .npmignore
and "prepublish"
script but I had no success and literally have no glue why this is happening.
Any tips would be very appreciated
To clarify:
npm
to keep the dist/
folder, bypassing the .gitignore
file (instead of defining an .npmignore
article here ) is to define a files
entry in the package.json
:{
"files": [
"dist",
"build",
...
]
}
postinstall
command. But it is clearly an anti-pattern. Given that I am writing a typescript library, that is tested and then compiled by the CI, there's no need to recompile it within the postinstall
command. But it could be an hacky solution when needed.{
"scripts": {
"postinstall": "tsc src/index.ts"
}
}
To sum up, I think it was only an npm cache
issue or more probably a server-side cache issue, because I've run npm cache clean --force
different times.
Hope this helps.