Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
770 votes
36 answers
1.6m views

Unable to resolve dependency tree error when installing npm packages

When trying to install the npm packages using npm i command, I am getting the following exception: I have tried reinstalling the Node.js package and setting the proxy to off using: set HTTP_PROXY= ...
Pearl's user avatar
  • 9,099
529 votes
33 answers
691k views

Can't run my Node.js Typescript project TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/App.ts

When I try to start my app on Heroku I got the following stack trace. It is just a basic ts.app like you see with ts-node and nodemon. I am really interested in what the answer is going to be. 2020-05-...
Elizar Pongracz's user avatar
497 votes
5 answers
148k views

How do I decide whether @types/* goes into `dependencies` or `devDependencies`?

I use TypeScript 2 in my project. I'd like to use some js library, but also typings for that library. I can install types with simple npm install @types/some-library. I'm not sure if I should --save ...
kamyl's user avatar
  • 6,206
414 votes
16 answers
689k views

npm WARN ... requires a peer of ... but none is installed. You must install peer dependencies yourself

I tried to run a project downloaded from github. Unfortunately, during npm install the following warnings were shown. I tried to change the version based on this question. However, I had a problem, ...
user avatar
291 votes
30 answers
517k views

'tsc command not found' in compiling typescript

I want to install typescript, so I used the following command: npm install -g typescript and test tsc --version, but it just show 'tsc command not found'. I have tried many ways as suggested in ...
Aung Thet's user avatar
  • 3,430
290 votes
11 answers
483k views

How to update TypeScript to latest version with npm?

Currently I have TypeScript 1.0.3.0 version installed on my machine. I want to update it to latest one i.e. 2.0. How to do this with npm?
blueMoon's user avatar
  • 2,991
206 votes
22 answers
66k views

Appending .js extension on relative import statements during Typescript compilation (ES6 modules)

This seems to be a trivial problem, but it is not very obvious what settings/configurations need to be used to solve this issue. Here are the Hello World program directory structure and the source ...
user3330840's user avatar
  • 7,175
179 votes
9 answers
169k views

ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead

I am getting this error ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead. Seems like Typescript updated but the Angular Compiler doesn't like ...
Matt's user avatar
  • 34.7k
140 votes
19 answers
114k views

NPM package cannot be used as a JSX Component - Type errors

Ive been getting these strange type errors on my typescript project for certain packages. Ex: 'TimeAgo' cannot be used as a JSX component. Its instance type 'ReactTimeago<keyof IntrinsicElements |...
Ray's user avatar
  • 1,698
127 votes
5 answers
119k views

How to consume npm modules from typescript?

I'm giving a shot at typescript. It works fine at the hello world stage. I'm now trying to use a npm module : index.ts = import _ = require('lodash') console.log(_.toUpper('Hello, world !')) This ...
Offirmo's user avatar
  • 19.5k
119 votes
11 answers
125k views

Is there a way to use npm scripts to run tsc -watch && nodemon --watch?

I'm looking for a way to use npm scripts to run tsc --watch && nodemon --watch at the same time. I can run these commands independently, but when I want run both of them, only the first one is ...
Nicolas Dominguez's user avatar
111 votes
6 answers
39k views

Writing npm modules in TypeScript

I am working on my first npm module. I briefly worked with TypeScript before and a big problem was that for many modules there were no definition files available. So I thought it would be a good idea ...
Andreas Gassmann's user avatar
106 votes
8 answers
198k views

How to install and run Typescript locally in npm?

I want to install and run Typescript (i.e. no global dependencies). Here is my package.json file: { "name": "foo", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { ...
Yahya Uddin's user avatar
  • 28.3k
103 votes
4 answers
53k views

TypeScript 2: custom typings for untyped npm module

After trying suggestions posted in other places, I find myself unable to get a typescript project running that uses an untyped NPM module. Below is a minimal example and the steps that I tried. For ...
Jodiug's user avatar
  • 5,883
91 votes
8 answers
260k views

"You may need an additional loader to handle the result of these loaders."

I am currently trying to build a State Management Library for ReactJs. But as soon as I implement it into my React project (created with create-react-app), it starts dropping this error: Failed to ...
BennoDev's user avatar
  • 1,247
75 votes
3 answers
120k views

How to import CSS from node_modules in webpack angular2 app

Let's say that we start with the following starter pack: https://github.com/angularclass/angular2-webpack-starter After npm install and npm run start everything works fine. I want to add an external ...
Burnee's user avatar
  • 2,583
71 votes
17 answers
113k views

How to debug 'npm ERR! 403 In most cases, you or one of your dependencies are requesting a package version that is forbidden by your security policy.'

I am currently trying to set up a Jenkins and a private npm repository (Sonatype Nexus). I get the following error when I try to publish to the repository within a Jenkins build pipeline. + npm ...
andymel's user avatar
  • 5,168
70 votes
13 answers
92k views

Cannot find name 'it' in Jest TypeScript

I try to create an intial setup for Jest in React + TypeScript. I have completed the initial setup and try to check whether the test runs. When I run the test using the command npm test, I am getting ...
Nidhin Kumar's user avatar
  • 3,513
68 votes
2 answers
43k views

Missing basic DOM types in TypeScript project

I am setting a web app up in TypeScript and I seem to be missing some basic types I need. When I compile (npm run build), I get the following errors, error TS2304: Cannot find name 'HTMLElement'. ...
James McMahon's user avatar
67 votes
2 answers
41k views

What is the pwa-node type launch configuration on VSCode?

I noticed that the default launch configuration generated by VSCode for npm debugging (Launch via NPM) sets the configuration type as "pwa-node" by default. Adding "Launch via NPM" ...
Wayrex's user avatar
  • 2,097
65 votes
3 answers
22k views

How to have npm install a typescript dependency from a GitHub url?

Consider the following scenario: There is a code library. The library is written in TypeScript and the typescript code is published in GitHub. The package.json file has a build script which creates ...
Jacob Horbulyk's user avatar
61 votes
19 answers
48k views

This is not the tsc command you are looking for

When I run tsc in the terminal (it does not matter where) I get returned: $ npx tsc --version This is not the tsc command you are looking for To get access to the TypeScript compiler,...
Björn Hjorth's user avatar
61 votes
8 answers
34k views

Next.js is not recognizing '@types/react'

When I try to run my Next.js app with npm run dev I get an error message saying that I don't have the required packages to run Next with Typescript: Please install @types/react by running: ...
G. Hruschka's user avatar
60 votes
17 answers
59k views

Typescript: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`

I've an npm command line application that i've built not so long ago and it worked fine. Now that i've updated it, and due to changes in the versions of typescript over the period, i'm getting an ...
crispengari's user avatar
  • 8,991
58 votes
12 answers
115k views

How to upgrade Typescript to the latest version?

I have a MacBook Pro with OS X 10.8.2 Some time ago I installed Typescript and today I'd like to upgrade that installation to the latest version available (so far, v0.8.3). I wrote this command from ...
Cesco's user avatar
  • 3,830
56 votes
9 answers
67k views

The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.8.3 was found instead

I starting getting this error on my Angular app: The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.8.3 was found instead and when I try to downgrade typescript to the right ...
guilhebl's user avatar
  • 8,810
55 votes
4 answers
12k views

Go to the TypeScript source file instead of the type definition file in VS Code

I created a custom npm library that is used in some root projects. This library is written in TypeScript. All sources are under a /src folder. The tsconfig.json of the library contains those compiler ...
electrotype's user avatar
  • 8,636
51 votes
5 answers
126k views

How to compile typescript using npm command?

I just wanted to know is there any command which will directly compile the typescript code and get the output. Right now, what I am doing is, every time when I make changes in the file I have to re-...
Lijin Durairaj's user avatar
48 votes
11 answers
65k views

How to use bootstrap 4 in angular 2?

I'm building an angular 2 app written in typescript. It would use the bootstrap 4 framework in combination with some custom theming, is this possible? The "ng2-bootstrap" npm package is not working ...
aqwsez's user avatar
  • 1,547
44 votes
8 answers
137k views

Module not found: Error can't resolve 'child_process', how to fix?

I'm trying to create a JupyterLab extension, it uses typescript. I've successfully added the package "@types/node" allowing me to use packages such as 'require('http')'. But as soon as I try ...
OneTwo's user avatar
  • 2,403
43 votes
1 answer
19k views

typings vs @types NPM scope

In some cases typings is used for handling TypeScript definitions (e.g. angular/angular2-seed). In other cases scoped NPM @types packages are used with no typings involved (e.g. AngularClass/angular2-...
Estus Flask's user avatar
41 votes
6 answers
44k views

How include node_modules in output directory with TypeScript

I want to know if it possible copy node_modules folder into output directory after run tsc command. My situation it that I have a project with TypeScript and use some npm packages. And i need that my ...
Vladimir Venegas's user avatar
41 votes
4 answers
32k views

How can I use "exports" in package.json for nested submodules and TypeScript?

I want to take advantage of the new-ish "exports" feature of Node.js/package.json so that I can do the following: "exports": { ".": "./dist/index.js", "...
Ryan Wheale's user avatar
  • 27.6k
40 votes
7 answers
49k views

Cannot find module 'ngx-bootstrap'

I'm having an issue in my application with ngx-bootstrap whereby it now can't detect the module unless you specify the path For example: import { BsModalService, BsModalRef } from 'ngx-bootstrap'; ...
chr15r's user avatar
  • 579
39 votes
10 answers
37k views

React npm start not working : 'No version of chokidar available'

I cloned my already working React-Typescript app on Github Pages, from Github and wanted to make some changes. I ran npm install and installed all the dependencies but when I run npm start, I got this ...
İlker's user avatar
  • 1,980
37 votes
5 answers
11k views

How to publish TypeScript modules on NPM without "dist" in import?

I'm trying to publish a typescript library on NPM but I can't to have a "good" path after publishing. I follow several guide on this point but I'm not found a solution. The problem: So, consider the ...
clem's user avatar
  • 867
36 votes
2 answers
15k views

How do I set a peer dependency optional?

I'm developing a module A. The user can, optionally, inject a Winston logger to my module, therefore winston is its peer dependency. Whenever I install my module A in another module where I don't want ...
John Smith's user avatar
  • 4,183
36 votes
2 answers
25k views

How to add a typescript definition file to a npm package?

Is there a way to add typescript definitions (.d.ts files) to a pure javascript project directly (e.g. in package.json). I can't find any documentation on that.
Michael_Scharf's user avatar
35 votes
9 answers
99k views

npm build gives "Ineffective mark-compacts near heap limit Allocation failed"

I have a reactjs/typescript project, running on windows 10. Im trying to build by ts-scripts with "rimraf ../wwwroot/* && react-scripts-ts build && copyfiles ./build/**/* ../...
Cowborg's user avatar
  • 2,793
35 votes
1 answer
8k views

Use a local module, using local dependency [duplicate]

I'm trying to include a local library, so i follow theese 2 tutorials: how to create library, how to consume local library. So, i have a nice sample library (it has package.json, index.ts, etc), i try ...
Vitalii Vasylenko's user avatar
34 votes
5 answers
8k views

Where are the TypeScript type declarations for Sign in With Google (GSI) library?

I'm implementing "Sign in with Google" using the Google "GSI" library. My application uses Next.js and TypeScript, so I'm looking for: An npm package including the GSI client ...
jameshfisher's user avatar
  • 36.4k
34 votes
5 answers
17k views

Sharing a typescript library in a monorepo

I'm trying to setup a monorepo with 3 services sharing some library code. This is the current situation: repo: web pdf/ package.json reference to shared-ts using github url tsconfig.json ...
Corentin S.'s user avatar
  • 5,920
32 votes
6 answers
61k views

Typescript build getting errors from node_modules folder

I am running a typescript build and getting errors in node_modules. Why isn't it ignoring this folder? I have it in the exclude section of my tsconfig.json. The really strange thing is that I have ...
Ryan Langton's user avatar
  • 6,334
32 votes
4 answers
30k views

Can't Resolve "encoding" Module Error While Using Nextjs-13 + Supabase

I'm trying to use Supabase for inserting/collecting data from my form. But when I compile I got encoding module is not found error. I already tried cache cleaning and re-installing npm modules. They ...
Poyraz HANCILAR's user avatar
32 votes
9 answers
28k views

How to resolve: "Definition for rule '@typescript-eslint/consistent-type-assertions' was not found"

My React app is not failing to compile due to the error: Definition for rule '@typescript-eslint/consistent-type-assertions' was not found I'm kind of at a loss. I'm unable to find any current rule ...
ezagala's user avatar
  • 321
30 votes
7 answers
13k views

Custom Library component is not a known element, but app compiles and runs

The Problem My html files warn that my custom components/pipes 'are not a known element'. However building and running the application works as intended, and the custom components/pipes are ...
Zen 's user avatar
  • 397
30 votes
1 answer
8k views

How to relate a version of @types package to the versions of the associated JS package?

I am working on a nodejs project with typescript 2.2 that is using node 6.3.1 and I want to migrate from using typings to using @types. By doing so I ran into a set of questions related to whether ...
Quim's user avatar
  • 358
29 votes
5 answers
98k views

Module not found: Error: Can't resolve 'stream' in 'C:\dev\jszip-test\node_modules\jszip\lib'

I'm using jszip v3.2.1 in an angular 7 application. When I build my project (running, for example, npm start) I'm getting the following error: ERROR in ./node_modules/jszip/lib/readable-stream-...
Ricardo Rocha's user avatar
28 votes
5 answers
27k views

TypeScript: Extend Express.Session interface with own class

I'm working on a Typescript project with npm packages. I want to add a property to the Express.Session interface. example Class: class User { name: string; email: string; password: ...
Mr. Smith's user avatar
  • 639
27 votes
3 answers
21k views

How to use npm link with a module written using TypeScript for development?

I am building a lib using TypeScript and Webpack. To develop this library I have created a separate test project (written using JS) and linked the library using npm link <package-name>. The ...
Denys Kozak's user avatar

1
2 3 4 5
54