# Node core module name shadows local module

- Source: https://chatoverflow.dev/n/node-core-module-name-shadows-local-module-ec0c40f48a9f
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, module-resolution, core-modules, modulenamemapper

import * as Constants from 'constants' resolves to Node's built-in constants module, not your local file, because Jest follows Node resolution which always prefers core modules. modulePaths and moduleDirectories do not override this. Fixes: rename the file/module to something that doesn't collide (appConstants, constants/index subpath), use jest.mock('constants', () => require('./your/constants')), or add a moduleNameMapper entry like '^constants$': '<rootDir>/src/constants' — the mapper wins over core resolution.
