What could be causing TypeScript to not locate my custom package?

I decided to create a fork of an existing package and released it with a new, distinct name:

https://www.npmjs.com/package/feed-media-fork

After tagging a new version, setting up a release on GitHub, and running yarn add feed-media-fork or the equivalent npm install feed-media-fork, everything seemed to work fine.

However, upon trying to import the library, TypeScript started throwing a "module not found" error.

import { Extension, Feed, FeedOptions } from 'feed-media-fork';

The outcome was:

error TS2307: Cannot find module 'feed-media-fork' or its corresponding type declarations.

What am I overlooking here?

Answer №1

To get your library up and running, make sure to compile it first

# Navigate to your library directory
npm install -g typescript
npm run build

Once you've compiled the library, importing it should work smoothly

Answer №2

Here is the content of your package:

https://www.npmjs.com/package/feed-media-fork?activeTab=code

The package currently does not include the compiled .js files and the .d.ts files. While including .ts files is not mandatory for npm packages, it is a good practice.

I suggest specifying the 'files' property in your package.json to clearly outline the contents of your package. If this is not done, NPM may default to using the .gitignore file which could exclude your compiled files.

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

Turn off the interconnected route while utilizing npm to display the tree of dependencies

If I want to display the project's dependencies tree using npm, I would use the following command: npm ls lodash The output will look something like this: > npm ls lodash npm info using [email protected] npm info using [email protected] ...

Utilizing Node.js and Jasmine: Preventing the invocation of a Promise function to avoid executing the actual code results in DEFAULT_TIMEOUT_INTERVAL

There is a function below that returns a promise. public async getAverageHeadCount(queryParams: Params, childNode: any, careerTrackId: string): Promise<Metric> { const queryId = this.hierarchyServiceApiUrl + "rolling-forecast/ahc/" + q ...

Angular 2 has its own version of $q.when called RxJs

Back in the AngularJS 1.* days, I used to have this code snippet to refresh the auth-token: ... if (!refreshTokenInProgress) { refreshTokenInProgress = AuthService.refreshToken(); } $q.when(refreshTokenInProgress, function () { refreshTokenInProgre ...

Angular encountered an ERROR of type TypeError where it cannot access properties that are undefined when trying to read the 'title'

I designed a form and I am trying to save the information entered. However, when I attempt to use the save method, an error keeps popping up. How can I troubleshoot this issue and successfully save the data from the form? ...

Fixing the error message stating 'Argument of type '{}' is not assignable to parameter of type 'any[]'. [ng] Property 'length' is missing in type '{}'. Here are steps to resolve this issue:

Currently, I am in the process of developing an Ionic Inventory Management application that incorporates a Barcode Scanner and SQLite database by following this tutorial: Upon adding the following code snippet: async createTables(){ try { awa ...

Troubles arise when attempting to utilize yarn for my projects

Whenever I enter the command yarn start in the terminal, I get this output: yarn run v1.22.4 $ react-scripts start 'react-scripts' is not recognized as an internal or external command, operable program or batch file. error Command fai ...

I downloaded NPM using PIP, however I am receiving the error message "npm: command not found"

Having Python 2.7 installed on OS X Yosemite 10.10.5, I attempted to install NPM via PIP. The installation seemed successful as there is a directory named npm in /Library/Python/2.7/site-packages/. However, whenever I try to use NPM, it returns "command no ...

Capture and store the current ionic toggle status in real-time to send to the database

I have a list of names from the database that I need to display. Each name should have a toggle button associated with it, and when toggled, the value should be posted back to the database. How can I achieve this functionality in an Ionic application while ...

Running npm audit fix with the --force flag did not resolve any issues

I removed the package-lock.json and node_modules, then ran npm i without success. I tried using yarn install instead, but it also did not work. Even after reinstalling NodeJS, the issue persisted. My npm version is 7.12.1 and npm audit fix didn't reso ...

When attempting to use the command "npm help update" in Windows, an error message is displayed indicating that the

My current setup includes nodejs v16.13.0 and npm 8.1.0. Whenever I try to run the command npm help update in cmd or PowerShell (both Admin and normal), I encounter this error: npm help update npm ERR! Invalid URL: file://C:%5CProgram%20Files%5Cnodejs%5Cn ...

Capture data from a Telegram bot and store it in a Google Sheet

I am trying to use a spreadsheet through a Telegram bot as a TODO list so that when I input something on my phone, it is saved in the spreadsheet. (I'm following this tutorial https://www.youtube.com/watch?v=XoTpdxbkGGk, which seems accurate with Goog ...

Tips for preventing a wrapped union type from collapsing

It seems like there is an issue with Typescript collapsing a wrapped union type when it knows the initial value, which is not what I want. I'm uncertain if this is a bug or intended behavior, so I'm curious if there's a way to work around it ...

How to dynamically incorporate methods into a TypeScript class

I'm currently attempting to dynamically inject a method into an external class in TypeScript, but I'm encountering the following error. Error TS2339: Property 'modifyLogger' does not exist on type 'extclass'. Here's the ...

Encountering the message "npm ERR! missing script: start" following the update to .Net 3.0

Previously, the ASP.Net Core 2.2 code (upgraded from 2.1) did not include a start script in package.json. https://github.com/TrilonIO/aspnetcore-angular-universal/blob/master/package.json Upon upgrading to ASP.Net Core 3.0, it now requires a start script ...

Error message: "ReferenceError occurred while trying to access the Data Service in

As I embark on the journey of creating my very first MEAN stack application - an online cookbook, I have encountered a challenge in Angular. It seems like there is an issue between the service responsible for fetching recipe data from the API (RecipeDataSe ...

Nestjs: Accessing the request or context using a Decorator

In my current project using NestJS, I am attempting to make the executionContext accessible in a logger for the purpose of filtering logs by request. Each injectable has its own instance of a logger, and I want to maintain this setup (where the scope of t ...

Error: Loki cannot be used as a constructor

Can anyone assist me in understanding why this code is not functioning correctly? Here's what my index.ts file in Hapi.js looks like: import { Server, Request, ResponseToolkit } from '@hapi/hapi'; import * as Loki from 'lokijs'; ...

Minimizing CSS Using Laravel Mix

Download Node.js Get NPM installed Navigate to the main directory of your project and open the file: webpack.mix.js. mix.styles([ 'public/css/vendor/normalize.css', 'public/css/vendor/videojs.css' ], 'public/css/all.css&ap ...

During rendering, the instance attempts to reference the "handleSelect" property or method which is not defined

I've incorporated the Element-UI NavMenu component into my web application to create a navigation bar using Vue.JS with TypeScript. In order to achieve this, I have created a Vue component within a directory called "navBar," which contains the follow ...

Encountering an error when attempting to connect a nodejs REST API to an HTTPS URL using port 844

Attempting to initiate an API call from Node.js to a Tomcat server using the http/https module. There are two options for the API URL: - Functioning correctly and receiving a response var options = { host: 'samleapiurl.com', port: ...