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

What is the issue with assigning type {intrinsicattributes & true} or type {intrinsicattributes & false} in a React and TypeScript environment?

I am facing an issue with the following code snippet: function Parent() { const count1 = 2; const count2 = 4; const isCount = count1 < 0 || count2 < 0; //setting isCount here return show ? ( <Dialog> ...

TypeORM issue - UnsupportedDataTypeError

Here is the entity file I'm working with, user.ts: @Entity('users') export class User { @PrimaryGeneratedColumn() id: number | undefined; @Column({ type: 'string', name: 'username', nullable: true }) username: s ...

manually setting up node dependencies

After learning about dependencies for Node, I discovered that they are not automatically installed with npm version 3.5.2. When I run npm install --no-optional, I receive the following warnings: npm WARN email protected requires a peer of @typescript ...

Challenges faced while setting up a fresh Angular 7 project

Encountered an error while trying to create a new project using angular cli. I attempted npm clear cache --force and manually deleted the npm cache folder, but neither solution resolved the issue. No proxy is needed for internet connection Ran command: n ...

Is it acceptable to include a @types library as a regular dependency in the package.json file of a Typescript library?

Should the library also be compatible with Typescript projects? I am developing a Typescript library that utilizes node-fetch and @types/node-fetch, which will be shared through an internal NPM registry within the company. If I only include @types/node-f ...

The specified container does not exist in the DOM: MERN

I am currently working on a project where I aim to develop a Web Application featuring a stock dashboard. During my coding process, I encountered a minor issue that can be seen in this image. My goal is to have a login form displayed on the browser using ...

Best practices for incorporating and leveraging node packages with Laravel Mix

As I embark on my Laravel (v 8.x) Mix project, I am encountering challenges when it comes to incorporating JavaScript from node modules. To kick things off, here is a snippet from my webpack.mix.js: mix.js('node_modules/mxgraph/javascript/mxClient.mi ...

What is the best way to apply ngClass to style a JSON object based on its length?

Currently, I am working with a mat-table that displays data from a JSON object. My goal is to filter out all records with an ID of length 5 and then style them using ngClass in my HTML template. How can I achieve this? Below is the code I am working with: ...

There was a problem with the WebSocket handshake: the response header value for 'Sec-WebSocket-Protocol' did not match any of the values sent

I've encountered an issue with my React project that involves streaming live video through a WebSocket. Whenever the camera firmware is updated, I face an error in establishing the WebSocket connection. Here's how I initiate the WebSocket: wsRe ...

Using JavaScript, generate an array of objects that contain unique values by incrementing each value by 1

I have an array of objects called arrlist and a parameter uid If the property value has duplicate values (ignoring null) and the id is not the same as the uid, then autoincrement the value until there are no more duplicate values. How can I achieve the a ...

Steps for combining TypeScript and JavaScript into a single file with npm scripts

Check out my complete package.json file here. "scripts": { "build": "webpack", "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\"", "lite": "lite-server", "postinstall": "typings install", "tsc ...

Node.js/NPM issue on Windows machine

I've encountered a situation where all npm commands are getting stuck indefinitely, no matter how long I wait. This issue seems to occur after using npm for a while. Currently, the only solution I have is to restart my PC (yes, resorting to Windows f ...

No noticeable difference was seen after implementing the recommendation provided by npm audit

We are currently using npm version 6.0.1 and upon running npm audit, we found some vulnerabilities in our projects. The first suggestion from the report is: # Run npm update fsevents --depth 4 to resolve 65 vulnerabilities I have tried running this comm ...

Running 'npm install' will install a package that is not currently being utilized

Currently focusing on a nodejs-express project, encountering an issue while attempting to execute "npm install" on a different machine. The installation process seems to include various modules not listed in the package.json file, including Angular. Any i ...

Steps to integrate Framework7 with Ionic 2

Is there a way to incorporate framework7 into a ionic2 project? I have successfully installed framework7 in my ionic2 project using the following command: npm i framework7 --save My next step is to add the typescript definition to the project by downloa ...

I am experiencing an issue with applying responsiveFontSize() to the new variants in Material UI Typography

I am looking to enhance the subtitles in MUI Typography by adding new variants using Typescript, as outlined in the documentation here. I have defined these new variants in a file named global.d.ts, alongside other customizations: // global.d.ts import * a ...

Guide to building a static method generator in TypeScript

Currently, I am working on creating a static method factory function in TypeScript. In my previous implementation using ES6, everything was functioning well and meeting my expectations. However, upon transitioning to TypeScript, I encountered a type-castin ...

Creating a definition for the use of sweet alerts within a service and incorporating them through

Implementing sweet alert for displaying alert messages in angularJS2/typescript. Due to the repetitive nature of this code in different parts of the application, a service was created. @Injectable() export class AlertMessageService { constructor(pr ...

Error message: Missing "@nestjs/platform-express" package when performing end-to-end testing on NestJS using Fastify

Just set up a new NestJS application using Fastify. While attempting to run npm run test:e2e, I encountered the following error message: [Nest] 14894 - 11/19/2021, 10:29:10 PM [ExceptionHandler] The "@nestjs/platform-express" package is missi ...

Sorting List Algorithm

Looking to create an algorithm in Node.js that abides by specific rules. It takes a series of numbers as input and the maximum consecutive number before taking a break. The logic is as follows: The rules : Only one competition per day Competitions are hel ...