I am getting File node_modules/@types/webrtc/index.d.ts is not a module with this code:
import * as webrtc from \"webrtc\";
const peerConnection1 =
No need to import anything, run following:
npm install --save @types/webrtc
update tsconfig.json -
"types": [ "@types/webrtc" ]
/// <reference types="@types/<your_types_module>" />
You may or may not want to do this depending on your build and style needs, but this seems to be the quick (and dirty) fix.
You probably want to add
"types": ["webrtc"]
to your tsconfig.json
, or less preferrably, to use
/// <reference types="webrtc" />
in your source files. Here's an example of it in your tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"sourceMap": true,
"noImplicitAny": true,
"types": ["webrtc"]
},
"exclude": [
"node_modules"
]
}
This tells TypeScript it should include webrtc
declarations in your build
Another option is to add a new declaration file *.d.ts
in your module, i.e.:
declare module 'my-module';
webrtc is part of the browser; you're trying to import a module. Simply import the (typings) library:
import "webrtc";
you may need to use "moduleResolution": "node"
in the compiler options.
Alternatively use the "types": ["webrtc"]
compiler option and the compiler will automatically load those types up for you.