Normi
Normi

Reputation: 41

NPM Link doesn't return any functions / classes of the module

Hello.

So, when i use npm link ../folder/ToFolder, this is work.

But, when i try to import any function, NOTHING is returned.

Better explanation

I've try to import the module i maked from another folder with npm link. When i try to import my module to the test one, no function is returned from the module i've imported.

My module is in TypeScript, my new test module is in JavaScript, did i did something wrong in the TS one?

Files

// module/src/index.ts

export * from "./functionA";
export * from "./functionB";

// Try in another method:

import { A } from "./functionA";
import { B } from "./functionB";
// These are folder, but they have index.ts that return the file with the functions.
export { A, B };
// test/index.js

const { A, B } = require("module");

const a = A.something();
const b = B.something();
// When i type only "A.", no functions found in autocomplete

Upvotes: 0

Views: 151

Answers (1)

refine-wind
refine-wind

Reputation: 36

You should check package.json of the module module, make sure the main field is set properly, otherwise,index.js will be used. Check this npm package.json

{ "main": "src/index.js" }

Upvotes: 0

Related Questions