npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Work with / build local package


I’m in need to develop a package, which will never be published to npm, but only shared locally with other developers and local projects. It’s kind of an API wrapper.

The actual project wants to use this package, thus it’s in local git. Available via git+ssh. Installing the package with npm install works in the way, that the sources are being fetched and put in to the correct node_modules directory.

But, the sources are not built. The package is Typescript API wrapper, which need to be build using “npm build”. The build script in package.json is simply “tsc”. Before tsc will work, npm install on this module needs to be executed, in order to fetch the required dev dependencies.

Can anyone explain what to do?


You might just need a prepare script which calls tsc. (I use prepare with my top-level TypeScript packages, but have not tried it in a git dependency.)

A variety of the lifecycle scripts are called for installing git dependencies to allow this sort of usage:

Ok, that works. At least half of it.

tsc transpiles the ts files to a js file, that’s good. But the tsconfig.json has "declaration": true, which should produce a index.d.ts file.

When I run npm build manually, this file is being created, prepare in turn does not create it.

"scripts": { "build": "tsc", "prepare": "tsc" }

Any idea?

Is the index.d.ts included in the “published” files? My understanding is the install from git is a bit like a clone+publish+install rolled together. So I would expect to see index.d.ts listed if you run this from your package:

npm pack --dry-run