0

I have import statements in my javascript file similar to the following:

import defaultExport1 from "module-name";
import defaultExport2 from "module-name";

Do I need the modules where the exports are located locally on my computer in order for the code to work?

ma p
  • 11
  • 3

2 Answers2

0

You may want to provide more context for a better answer...

Are you using Webpack to build a deliverable bundle for a front end application?

What kind of modules are you pulling in? Are these modules you plan to get "install" with npm?

In general, if you use the command "npm install module-name", the modules will be installed in the node_modules folder. If the module is in that folder, webpack will pick it up for you.

tophstar
  • 75
  • 1
  • 9
0

There is no single interpretation of module names in import statements – they will work differently when run in the browser or with Node, and bundling tools such as Webpack may give them special meaning.

If you’re using Node, the modules you are referencing are most likely npm packages. You should make sure you have a package.json that references the modules you are importing, then run npm install in the same directory as the package.json. This will install the modules to your local node_modules folder.

Rory O'Kane
  • 29,210
  • 11
  • 96
  • 131