What are the steps to create a project using TypeScript and your neighborhood library?

As I work on developing my app that requires a library written in TypeScript and normally installed via npm, I find myself frequently needing to make edits to it. Ideally, I would like to be able to directly edit the library and see the changes reflected in my app. Despite trying npm link, I have not had success. How can I make this work with TypeScript?

Answer №1

If you want to utilize your library in project P, make sure it is compiled before linking with npm link.

Assuming both project P and library L are local within a directory structure like this:

./repos
    ./P
        project.json
    ./L
        ./src
        ./dist
        project.json

In the file /repos/L/project.json, ensure that there is an entry for main pointing to the main file located inside the dist folder of the library. To generate the dist folder, compile the library using tsc.

Here's what you need to do next:

$ cd repos/L
$ tsc      # or alternatively npm run build
$ cd ../P
$ npm link ../L

And just like that, you're good to go.

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

No data found on Angular TypeScript page with an empty array

Incorporated a function called 'getQuestionsWithInterviewId' to populate my 'Questions' string, but it appears empty when I attempt to call it within the ngOnInit and ngAfterContentInit methods and log the result in the console. import ...

The Gatsby development command seems to be malfunctioning as it displays a TypeError stating: "is.urlInstance is not a

Error: is.urlInstance function not available Encountering dependency issues after attempting to update gatsby version without success. npm error code ERESOLVE Unable to resolve dependency tree While resolving: [email protected] Found: [email pr ...

Why does npm keep removing my npm directory whenever I attempt to set up gulp?

I placed node in a "custom" location: c:\Apache24\htdocs\node\ Everything seems to be in place. Upon running: $ npm install --global gulp-cli as recommended by the documentation, it appears to install successfully. However, when ...

Facing a EACCES symlink error while trying to setup expo-cli

I am encountering some difficulties while attempting to install expo-cli using the command npm install -g expo-cli. Despite looking through other similar posts, none of the recommended solutions seem to work for me. I suspect that the issue lies in the way ...

Executing npm i on a Windows system will generate the EBADPLATFORM error for an unsupported platform

After originally developing my React project on a Mac, I switched to using my Windows device. When running npm i to set up the project, I encountered the following error: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, ...

Triggering multiple updates within a single method in Angular will cause the effect or computed function to only be triggered

Upon entering the realm of signals, our team stumbled upon a peculiar issue. Picture a scenario where a component has an effect on a signal which is a public member. In the constructor of the component, certain logic is executed to update the signal value ...

Is Angular 9's default support for optional chaining in Internet Explorer possible without the need for polyfill (core-js) modifications with Typescript 3.8.3?

We are in the process of upgrading our system to angular 9.1.1, which now includes Typescript 3.8.3. The @angular-devkit/[email protected] utilizing [email protected]. We are interested in implementing the optional chaining feature in Typescript ...

What is preventing the exclusion of the null type in this specific situation within Typescript?

type NonNullableCopy<O> = { [p in keyof O] -?: O[p] extends null | undefined ? never : O[p]; }; type Adsa = {a?: number | null} type Basda = NonNullableCopy<Adsa> let asd : Basda = { a: null // Still valid. No errors } Although it see ...

Exploring the Use of 7BitEncodedInt in JavaScript

Currently, I am trying to read a binary file using JavaScript. It appears that this file may have been written in C#, which handles strings differently from how it's done in the source mentioned at https://learn.microsoft.com/en-us/dotnet/api/system. ...

Angular 4: Implementing toggle switch functionality in Angular 4 by binding boolean values retrieved from the database

Within my application, I am facing an issue with binding a toggle switch to data stored in the database. The data in the database is represented by a field called Status, which can have values of True or False. My goal is to incorporate toggle switch butto ...

Insert information into a 3-tiered nested Angular FormArray within interconnected dropdown fields

After trying to retrieve data from an API call to populate a select form field, I encountered difficulties setting the value correctly using a FormArray. This led me to creating a FormArray with 3 nested levels in Angular, taking reference from this examp ...

`Changing environment variables in Angular during execution`

I am looking for a way to dynamically change the URL that my Angular application fetches resources from during build time. I want to be able to pass a parameter while building in order to modify the URL value, particularly for deployment in different Docke ...

The module 'crypto-js' or its corresponding type declarations cannot be located

I have a new project that involves generating and displaying "QR codes". In order to accomplish this, I needed to utilize a specific encoder function from the Crypto library. Crypto While attempting to use Crypto, I encountered the following error: Cannot ...

Issue: The requested file or directory '/root/.ionic/daemon.log' does not exist

Recently, I encountered an error on Windows 10. In an attempt to resolve it, I performed a clean installation of Ubuntu over my existing Windows system, wiping everything out. However, even after downloading the latest versions of NodeJS, Ionic, and Cordov ...

Encountering errors while attempting to install TypeScript through NPM

I am encountering an issue while trying to install Typescript using npm. Following the documentation, I executed the command: npm install -g typescript or sudo npm install -g typescript - Everything seems to be going smoothly until it reaches about 2 ...

Error message "404 Not Found" encountered when attempting to publish a package via NPM on GitLab

Whenever I try to upload a package to a package repository on my private GitLab instance using NPM and GitLab's 'instance-level' scope/namespace configuration, I keep encountering a frustrating 404 Not Found error (source). The Error Message ...

Tips for troubleshooting and resolving the npm ERR_SOCKET_TIMEOUT issue during the creation of a react app

When I use npx create-react-app to start my project, the installation process crashes with this error message: npm ERR! code ERR_SOCKET_TIMEOUT npm ERR! errno ERR_SOCKET_TIMEOUT npm ERR! network Invalid response body while trying to fetch https://registry. ...

Issues with displaying images have been encountered with the Chessboardjs NPM package

Currently, I am attempting to utilize the https://www.npmjs.com/package/chessboardjs package in conjunction with meteor 1.13. Despite developing a simple react component to display the board, the images are not rendering as expected. Below is the code for ...

What steps should I follow to update my NextJS version from v11 to v13?

I am currently working on upgrading the dependencies of my NextJS project to address security vulnerabilities using npm v9.5.1. The reason behind this task is the detection of a security issue by npm audit in my project: node-fetch <2.6.7 Severity: hi ...

Tips for properly sending a JWT token

When working on my angular application, I encountered an issue while trying to send a jwt token as a header for request authorization. The error 500 was triggered due to the jwt token being sent in an incorrect format. Here is how I am currently sending it ...