Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how dotenv is imported #327

Closed
wants to merge 1 commit into from

Conversation

SwarnenduG07
Copy link

This error is shwoing when using

import "dotenv/config"

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\Coding\Solana\solKeyPair\node_modules.bin\node_modules\dotenv\config.js' imported from D:\Coding\Solana\solKeyPair\node_modules.bin\esrun-1723634828132.tmp.mjs Did you mean to import ../../dotenv/config.js?

IF you use this then this error will be gonr

Problem

Summary of Changes

Fixes #

This error is shwoing when using 
```
import "dotenv/config"
```
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\Coding\Solana\solKeyPair\node_modules\.bin\node_modules\dotenv\config.js' imported from D:\Coding\Solana\solKeyPair\node_modules\.bin\esrun-1723634828132.tmp.mjs
Did you mean to import ../../dotenv/config.js?

IF you use this then this error will be gonr
@mikemaccana
Copy link
Collaborator

mikemaccana commented Aug 20, 2024

@SwarnenduG07 I can't replicate this not working.

import 'dotenv/config' comes from the official dotenv docs

How do I use dotenv with import?
Simply..
import 'dotenv/config'

Do you actually have a file called .env in the top level of your project?

What happens when you:

  1. Make. a folder with a .env with the contents:
FOO=BAR

2 Make a file called runme.ts:

import "dotenv/config";
console.log(process.env.FOO);
  1. Run this with npx esrun runme.ts ?

@mikemaccana mikemaccana changed the title Update intro-to-cryptography.md Change how dotenv is imported Aug 20, 2024
@mikemaccana mikemaccana added the question Further information is requested label Aug 20, 2024
@ElDeepFull
Copy link

ElDeepFull commented Aug 24, 2024

I think there are issue with @solana-developer/helpers. library and
import { getKeypairFromEnvironment, } from "@solana-developers/helpers";

const user = getKeypairFromEnvironment("KEY") //Not work

So use simply use console.log("KEY:", process.env.KEY); to laod your key from.env file.

@jacobcreech jacobcreech closed this Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants