For security reasons I need to setup a custom npm-registry.
I configure a local http-registry (nginx) using this command:
npm config set @example:registry=http://localhost/
Then I place two files to nginx
.
..
@example%2fmodel
model.tgz
The contents of @example%2fmodel
is:
{
"name":"Model",
"dist-tags":{"foo":"1.0.0"},
"versions":{
"1.0.0":{
"version":"1.0.0",
"dist":{"tarball":"model.tgz"}
}
}
}
The content of model.tgz
is the package.json
and the Model.ts
.
The the Model.ts
(from tarball) is:
export const URL = 'https://example.com/';
export const USER = 'apiv2';
export const PASS = '***';
The package.json
(from tarball) is:
{"name":"Model","version":"1.0.0","files":"*.ts"}
As you can see, its all minimal and all straightforward.
Then I do a:
npm install @example/model
added 1 package in 0.347s
npm info ok
That worked well. But my Model.ts
is missing
2
Answers
The optional
files
attribute field is an array of file patterns.So based on the above, your
package.json
should look like the following:The square array brackets
[]
ensures any declared type of file within it will be included in the tarball when it’s packed.See documentation here: Configuring NPM: package.json – files attribute
Adding
fileCount
andunpackedSize
under thedist
object in@example%2fmodel
could helpfileCount
– the total count of files included in the tarball (in your case it’s2
)unpackedSize
– the size of unpacked package, in bytesThe
@example%2fmodel
file then looks something like this:Change the
unpackedSize
to the actual size of te package.