Does ES6 module importing execute the code inside the imported file?

Yes, it does, exactly one time.

See http://www.ecma-international.org/ecma-262/6.0/#sec-abstract-module-records:

Do nothing if this module has already been evaluated. Otherwise, transitively evaluate all module dependences of this module and then evaluate this module


The accepted answer is not fully correct.

A module will execute once when imported, but... it is possible to have multiple copies of a module installed in a project, in which case the code will be executed multiple times!

Consider what happens if a.js, b.js and c.js are in three separate packages (package_a, package_b and package_c respectively) and package_b and package_c both specify package_a as a dependency, and your project specifies package_b and package_c:

node_modules/
├── package_b/
│   └── node_modules/
│       └── package_a/
|           └── a.js
└── package_c/
    └── node_modules/
        └── package_a/
            └── a.js

Because package_a will be installed twice (as far as your project is concerned these are two totally different packages) the code in a.js will be imported, and therefore executed twice!

Many people landing on this question are unlikely to be aware of this quirk of node, yet probably need to be if they landed on this question.

Here is an old but good article on understanding-the-npm-dependency-model with further detail on how and why npm does this.