I use VisualStudio 2019 with TypeScript3.9 and Libman.
And I need Bootstrap4 and jQuery. So try get these libraries and typings(index.d.ts) by Libman.
Then Bootstrap4 typing(index.d.ts) get error "Cannot find module popper.js".
// Type definitions for Bootstrap 4.5
// Project: https://github.com/twbs/bootstrap/, https://getbootstrap.com
// Definitions by: denisname <https://github.com/denisname>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery"/>
import * as Popper from "popper.js"; // ERROR!: "Cannot find module popper.js"
I found similar problems and answers.
- Bootstrap 4 TypeScript Type Definition fails to compile - Cannot find module 'popper.js'
- Cannot find module "popper.js" Angular 5 Visual Studio 2017 asp.net core
- Angular @types/bootstrap error: Namespace 'popper.js' has no exported member
It could only solve the problem temporarily.
I changed bootstrap4 typing(index.d.ts) to relative path as import * as Popper from "../popper_v1";
is fixed error.
But Libman override this manually-changed index.d.ts.
_
What can I do to fix this error? Do I need to install manually modified index.d.ts, like Popper v1.X?
Thanks.
Steps to reporduce error.
Create ASP.Net4 MVC Project on .Net Framework 4.8
Create libman.json to add some libraries and TS typings
{
"version": "1.0",
"defaultProvider": "jsDelivr",
"libraries": [
{
"library": "bootstrap@4.5.2",
"destination": "lib/bootstrap/"
},
{
"library": "@types/bootstrap@4.5.0",
"destination": "lib/types/bootstrap/"
},
{
"library": "jquery@3.5.1",
"destination": "lib/jquery/",
"files": [
"dist/jquery.js",
"dist/jquery.min.js",
"dist/jquery.min.map",
"dist/jquery.slim.js",
"dist/jquery.slim.min.js",
"dist/jquery.slim.min.map",
"external/sizzle/LICENSE.txt",
"external/sizzle/dist/sizzle.js",
"external/sizzle/dist/sizzle.min.js",
"external/sizzle/dist/sizzle.min.map",
"AUTHORS.txt",
"LICENSE.txt",
"README.md"
]
},
{
"library": "@types/jquery@3.5.1",
"destination": "lib/types/jquery/"
},
{
"library": "@types/sizzle@2.3.2",
"destination": "lib/types/sizzle/"
},
{
"provider": "cdnjs",
"library": "popper.js@1.16.1",
"destination": "lib/popper.js/"
},
{
"provider": "filesystem",
"library": "lib_ManualInstallSources/popper_v1/",
"destination": "lib/types/popper_v1/"
}
]
}
** Note: I got typing(index.d.ts) of popper.js ver.1.X from GitHub repository.
- Create tsconfig.json
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"lib": [ "ES6", "DOM" ],
"baseUrl": ".",
"typeRoots": [
"./lib/types"
]
},
"exclude": [
"node_modules",
"wwwroot",
"lib"
]
}
After these steps, bootstrap4 typing(index.d.ts) get error "Cannot find module popper.js" on import * as Popper from "popper.js";
.