hshi
hshi

Reputation: 39

cannot use alias in npm package

im trying to create a npm package that i can use in my other app. in my development i defined path in tsconfig for importing different modules instead of relative path. however, when i download my package in to test app. it cannot resolve module path.

i think if i change to using relative path then it would work.

in my tsconfig, i defined a path like this

"moduleOne": ["./moduleOne/src/index.ts"]

in my ts file where i need to import moduleOne i do

import {helper} from "moduleOne"

when i download the package in my other app i get Module not found: Error: Can't resolve 'moduleOne'

Upvotes: 1

Views: 844

Answers (2)

johannchopin
johannchopin

Reputation: 14844

Try with

import { helper } from "moduleOne"

Upvotes: 1

Madyson
Madyson

Reputation: 26

You're missing the string quotations around moduleOne on the import.

Upvotes: 1

Related Questions