solana-developers / helpers

JS/TS helpers for Solana
https://www.npmjs.com/package/@solana-developers/helpers
65 stars 17 forks source link

Cannot find module '@solana-developers/helpers' or its corresponding type declarations #32

Closed GiorgosK closed 3 months ago

GiorgosK commented 5 months ago

As part of this tutorial https://www.soldev.app/course/intro-to-writing-data there is this line

import { getKeypairFromEnvironment, airdropIfRequired } from "@solana-developers/helpers";

after adding/install with npm i @solana-developers/helpers I still get the following error reported by vscode

Cannot find module '@solana-developers/helpers' or its corresponding type declarations

and when running the ts file

Could not resolve "@solana-developers/helpers"

Even though I can see the package in "node_modules/@solana-developers/helpers"

GiorgosK commented 5 months ago

After a lot of soul searching ended up building the actual installed package

$ cd node_modules/@solana-developers/helpers
$ npm run build

> @solana-developers/helpers@2.2.0 build
> tsup src/index.ts --dts

sh: 1: tsup: not found
$ npm i tsup -D
...
$ npm run build

> @solana-developers/helpers@2.2.0 build
> tsup src/index.ts --dts

CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v7.2.0
CLI Target: es2022
CJS Build start
CJS dist/index.js 10.25 KB
CJS ⚡️ Build success in 21ms
DTS Build start
DTS ⚡️ Build success in 1069ms
DTS dist/index.d.ts 1.86 KB

After that the initial error was gone

lucky-gru commented 5 months ago

In my case, the lib was fetched from Github, not NPM Probably something went wrong when publishing v2.2.0. So you can skip that issue by specifying a certain version.

npm i @solana-developers/helpers@latest

npm i @solana-developers/helpers@2.2.0

mikemaccana commented 5 months ago

hrm I can't replicate here.

mkdir deleteme
cd deleteme
npm init -y
npm i @solana-developers/helpers
edit runme.ts
npx esrun runme.ts

runme.ts is:

import {
  getKeypairFromEnvironment,
  airdropIfRequired,
} from "@solana-developers/helpers";

console.log(getKeypairFromEnvironment);

The file runs and the function is found and logged.

@GiorgosK what happens when you do this?

@lucky-gru when you say "In my case, the lib was fetched from Github, not NPM" did you run npm i @solana-developers/helpers or install via some other way?

lucky-gru commented 5 months ago

@mikemaccana I tried

npm i @solana-developers/helpers

mikemaccana commented 4 months ago

Do you still get this with 2.3.0?

Please follow these instructions and report results (same as previous)

mkdir deleteme
cd deleteme
npm init -y
npm i @solana-developers/helpers
edit runme.ts
npx esrun runme.ts

runme.ts is:

import {
  getKeypairFromEnvironment,
  airdropIfRequired,
} from "@solana-developers/helpers";

console.log(getKeypairFromEnvironment);
mikemaccana commented 3 months ago

Haven't gotten any reply to this, it seems like it's dead. Closing...