Typescript library available as a private npm dependency

I have developed a Typescript library that I bundle as an npm module. During the development of my frontend application, I easily integrated this library using yarn link.

As I set up GitLab CI for other developers to work on the frontend application, I am facing challenges with distributing this package.

The possible solutions I have considered and the issues I am encountering are:

  • yarn add <git-url>

While this adds the source code, it remains uncompiled due to being in typescript. Compiling multiple files using the same tsconfig.json is not working for me, only one file gets compiled.

Moreover, developers' machines blocking port :22 hinders them from using git+ssh, making it difficult for both developers and CI to retrieve this package successfully.

  • yarn add tar-ball

Even when attempting to use a tarball, there isn't a clear way to store it. GitLab doesn't provide access to artifacts generated from builds for other CI pipelines.

  • vendoring the package

To tackle this issue, I decided to include the node module in the git repository. However, I haven't found a reliable way to prevent yarn from automatically removing this package. Including the library in node_modules results in its removal upon running yarn.

Although switching to a private npm module is an option, I believe there should be simpler alternatives for distributing internal packages if you already have a well-functioning GitLab environment.

Is there a way to privately distribute a Typescript package without relying on an NPM private registry?

Answer №1

If you want to vendor the package but keep it in a custom directory (instead of under node_modules), you can do so by placing it in, for example, my-library. Then, in the dependencies section of your package.json, add "my-library": "link:my-library". This will prompt Yarn to create a symbolic link from node_modules/my-library to my-library. For more details on the link: syntax, refer to this thread.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it necessary to include full absolute paths in links within markdown files of GitHub repositories in order to successfully publish the package to npm?

Imagine we have a GitHub repository containing 2 Markdown files: README.md Documentation/SampleDocumentationPage.md In the README.md, we can reference the SampleDocumentationPage using relative or shortened absolute paths: See [sample documentation page] ...

I am encountering an error that states: UnhandledPromiseRejectionWarning: TypeError: Unable to retrieve the property 'buffer' as it is undefined

I am facing an issue with my code where I am unable to upload new files to my website. Can someone help me understand what might be causing this problem? const multer = require("multer"); const upload = multer({ storage: multer.memoryStorage() ...

Utilizing the Route.post() method in Node.js

I'm currently developing a Node.js application and I'm facing an issue while trying to access functions from my index.js file in the calls.js controller. Every time I include var IndexBot = require('/root/afstudeerwerk/chatbotPIROS/index&ap ...

Installation of node and npm using brew on OSX 10.9.4 encountered an error

After spending a few hours trying to solve this, I believe I have encountered a new problem: $ brew install node -v ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node- 0.10.31.mavericks.bottle.tar.gz .. npm ERR! Error: EACCES, ...

npm encountered an error with code EPEERINVALID, indicating an issue with

Welcome, I'm a new member here and encountering an npm ERR! code EPEERINVALID. Currently, my setup includes: nvm 0.32.1 npm 2.15.9 node v4.5.0 grunt-cli v1.2.0 grunt v0.4.5 While attempting to upgrade a package or module, I came across the foll ...

Why is my React component not being updated with Routes?

I'm new to using react-router and I'm struggling with it for the first time. Here is the code snippet: App.tsx import React from 'react'; logo = require('./logo.svg'); const { BrowserRouter as Router, Link, Route } = require ...

Is it considered a bad practice to simply paste a package name into Package.json?

What is the difference between adding a package name in your package.json file and running npm i versus running npm i package-name directly? In package.json: "dep": 1.0.0 vs. npm i dep --save We encountered a build error and discovered that we could b ...

Unable to deploy Firebase functions following the addition of an NPM package

Scenario: I recently tried integrating Taiko into my Firebase web application, similar to Puppeteer. It's worth mentioning that Taiko downloads Chromium for its operations. Challenge: Ever since then, none of my functions are deploying successfully. ...

Assigning value to a member variable in a TypeScript Angular class

Currently, I am in the process of learning Angular. To enhance my skills, I am developing a simple web application using Angular and Spring Boot. One challenge I encountered is assigning a variable to the member variable of a Class. import { Injectable } f ...

You may encounter the error MSB8020 stating that the build tools for v141 (Platform Toolset = 'v141') cannot be located while attempting to install the npm module scrypt

I am currently attempting to install the npm module scrypt onto my system. After conducting some research, I found out that scrypt requires node-gyp for installation. Despite installing node-gyp globally multiple times, I continue to encounter issues. Add ...

Creating a unique object by dynamically incorporating features from another object

I've recently implemented a tree structure in my UI using Material Tree, and it requires creating a new object to represent the tree. The initial object format is as follows: [ { name: 'Fruit', children: [ {name: 'Apple& ...

Tips for avoiding the error message "Expected 1 arguments, but got 0" when the specified argument is actually `undefined`

Current Typescript Version: 2.6.2 I am in the process of enhancing the type safety of redux beyond what is provided by default typedefs, while also streamlining some of the redundant code. I believe I am edging closer to my desired setup, with just one is ...

Utilizing external JavaScript libraries in Typescript for integration with nodeJS

We've recently made the switch to using Typescript + Electron for developing a browser-based desktop application. However, we often encounter delays when loading external Javascript libraries. While typings helps with most of our needs, there are stil ...

Install a package from a local directory with npm

I am encountering an issue due to a firewall blocking git connections on port 9418. In order to work around this, I want to install a repository via npm (mysam https://github.com/mysamai/mysam). My attempt to install directly using npm --proxy <proxy-d ...

The upcoming development does not involve creating an entire HTML webpage using on-demand static site generation (SS

I’m encountering a problem when utilizing getStaticPaths and getStaticProps to create an on-demand SSG for a sharing page. My setup involves Next v12.1.0 and React 17.0.2. After building a specific /[id] page, I can retrieve the data but the HTML output ...

Troubleshooting Error: Module build failure in node-sass and sass-loader. TypeError encountered: 'this.getResolve' is not a function within the

I'm currently following a tutorial that instructs me to install both node-sass and sass-loader. However, upon installation, I encountered the following error: ERROR Failed to compile with 1 errors ...

Customizing Angular Forms: Set formcontrol value to a different value when selecting from autocomplete suggestions

How can I mask input for formControl name in HTML? When the autocomplete feature is displayed, only the airport's name is visible. After users select an airport, I want to show the airport's name in the input value but set the entire airport obje ...

Managing middleware in tRPC: Utilizing multiple methods for a single route call?

We're currently working on a group project with a tight deadline of just a few weeks. Our team has opted to utilize the T-3 stack for this project and have chosen tRPC as the server framework. While I am familiar with express, I am finding it challeng ...

Managing updates with the spread syntax: Dealing with undefined or null properties

Let's take a look at this example method: GetCustomerWithPoints(customerId: number): Customer { const customer = this.customerService.getCustomer(customerId); const points = this.pointService.getPointsForCustomer(customerId); return {...custo ...

Enhance your images with the Tiptap extension for customizable captions

click here for image description I am looking to include an image along with an editable caption using the tiptap extension Check out this link for more information I found a great example with ProseMirror, but I'm wondering if it's possible ...