Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
Error importing / exporting enum from npm package

I created an npm package with some typescript models that has the following folder structure:

src
-- enums
---- PRODUCT_MATERIAL.ts
index.ts

PRODUCT_MATERIAL.ts

enum PRODUCT_MATERIAL {
    PLASTIC,
    ALUMINUM,
    STAINLESS_STEEL
}

export default PRODUCT_MATERIAL;

index.ts

export { default as PRODUCT_MATERIAL } from './enums/PRODUCT_MATERIAL';

After building the package with the tsc command these are the generated files:

index.js

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PRODUCT_MATERIAL = void 0;
var PRODUCT_MATERIAL_1 = require("./enums/PRODUCT_MATERIAL");
Object.defineProperty(exports, "PRODUCT_MATERIAL", { enumerable: true, get: function () { return __importDefault(PRODUCT_MATERIAL_1).default; } });

index.d.ts

export { default as PRODUCT_MATERIAL } from './enums/PRODUCT_MATERIAL';

PRODUCT_MATERIAL.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PRODUCT_MATERIAL;
(function (PRODUCT_MATERIAL) {
    PRODUCT_MATERIAL[PRODUCT_MATERIAL["PLASTIC"] = 0] = "PLASTIC";
    PRODUCT_MATERIAL[PRODUCT_MATERIAL["ALUMINUM"] = 1] = "ALUMINUM";
    PRODUCT_MATERIAL[PRODUCT_MATERIAL["STAINLESS_STEEL"] = 2] = "STAINLESS_STEEL";
})(PRODUCT_MATERIAL || (PRODUCT_MATERIAL = {}));
exports.default = PRODUCT_MATERIAL;

PRODUCT_MATERIAL.d.ts

declare enum PRODUCT_MATERIAL {
    PLASTIC = 0,
    ALUMINUM = 1,
    STAINLESS_STEEL = 2
}
export default PRODUCT_MATERIAL;

When importing import { Product, PRODUCT_MATERIAL } from '@attebyte/petscan-models'; and building my project, I get the following error:

Failed to compile.

Attempted import error: 'PRODUCT_MATERIAL' is not exported from '@attebyte/petscan-models' (imported as 'PRODUCT_MATERIAL').

Why am I not able to import my enum? It is clearly exported in both the index.js and declaration file of my package.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!