I currently utilize VisualStudio 2019 combined with TypeScript3.9 and Libman.
My requirement is for Bootstrap4 and jQuery libraries to be incorporated.
To achieve this, I attempt to obtain these libraries and typings(index.d.ts) via Libman.
However, upon obtaining the Bootstrap4 typing(index.d.ts), an error occurs stating "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"
Given similar queries raised in various communities:
- 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
A mere temporary fix was identified.
In my case, altering the bootstrap4 typing(index.d.ts) to a relative path such as
import * as Popper from "../popper_v1";
proved effective in resolving the issue.
Sadly, Libman overrides any manual adjustments made to the index.d.ts file.
_
The puzzle remains: How can I rectify this error?
Perhaps opting to install manually modified index.d.ts with Popper v1.X could offer a solution?
Your insights are greatly appreciated.
Steps to Reproduce the Error:
Initiate ASP.Net4 MVC Project on .Net Framework 4.8
Formulate libman.json to include desired libraries and TS typings
{
"version": "1.0",
"defaultProvider": "jsDelivr",
"libraries": [
{
"library": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b1914140f080f091a0b3b4f554e5549">[email protected]</a>",
"destination": "lib/bootstrap/"
},
{
"library": "@types/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="caa8a5a5beb9beb8abba8afee4ffe4fa">[email protected]</a>",
"destination": "lib/types/bootstrap/"
},
{
"library": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="90fae1e5f5e2e9d0a3bea5bea1">[email protected]</a>",
"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/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="315b404454434871021f041f00">[email protected]</a>",
"destination": "lib/types/jquery/"
},
{
"library": "@types/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b0c3d9cacadcd5f0829e839e82">[email protected]</a>",
"destination": "lib/types/sizzle/"
},
{
"provider": "cdnjs",
"library": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e3938c93938691cd8990a3d2cdd2d5cdd2">[email protected]</a>",
"destination": "lib/popper.js/"
},
{
"provider": "filesystem",
"library": "lib_ManualInstallSources/popper_v1/",
"destination": "lib/types/popper_v1/"
}
]
}
** Note: The typing(index.d.ts) of popper.js ver.1.X was sourced from the 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"
]
}
Subsequent to performing these steps, the Bootstrap4 typing(index.d.ts) triggers an error stating "Cannot find module popper.js" when using
import * as Popper from "popper.js";
.