My ASP.net application in Visual Studio used to only utilize JavaScript, but now I am looking to incorporate Typescript. While the installation and transpiling process went smoothly, I encountered an issue when attempting to import modules.
I decided to use npm for loading modules, such as adding the following to my package.json
:
"devDependencies": {
"typestyle": "^1.7.1",
}
This module should be imported in my .ts file using:
import { style } from 'typestyle';
The problem arises when npm downloads the files to a folder named node_modules
which is not recognized within my project directory; hence, the import statement cannot locate the necessary files.
For the time being, I have resorted to using requirejs to facilitate import statements, as explained here. Here is how my tsconfig.json
currently appears:
{
"compilerOptions": {
"noImplicitAny": true,
"noEmitOnError": true,
"sourceMap": true,
"target": "es5",
"module": "amd",
"moduleResolution": "node"
}
}
Although I could manually download typestyle.js
, place it within my project folder, and configure the requirejs configuration file, main.js
, to recognize it, this approach does not involve using npm.
How can I successfully import modules that have been loaded with npm? Preferably through requirejs without introducing additional complexities like Angular or React, Mocha, node.js, knockout, Webpack, Gulp, Browserify, etc.
EDIT
After exploring the differences between NPM, Bower, Browserify, Gulp, Grunt, and Webpack on this source, it seems that opting for a module bundler like Webpack or Browserify may be necessary. Is there a tool integrated in VS2017 that could fulfill this role?
EDIT2
Furthermore, after pondering over the experience shared in How it feels to learn JavaScript in 2016 (although dated 2018), it dawned on me that seeking a straightforward solution might prove challenging...