0

I am trying to get the seed words from the powershell command prompt. Hence I am using the 'dotenv' in truffle.js

require('dotenv').config();
console.log('aa - process.env.MNEMONIC : '+mnemonic);

Later in powershell, I am issuing the command.

MNEMONIC="Let us code ICO" truffle migrate --reset --network ropsten

When I see the console log statement I see the value in "process.env.MNEMONIC " as undefined. Could you please help in resolve this error ?

enter image description here

Option 2: I have created the .env file and tried to access it in the truffle.js as shown below. Still I am unable to access it. The value still shows as undefined.

enter image description here

2

The issue is not related to dotenv, the message tells you that MNEMONIC=... is not recognized as the name of a cmdlet

You need to define .env file with MNEMONIC setting, or run command (Windows):

Command Prompt

set MNEMONIC=Let us code ICO && truffle migrate --reset --network ropsten

PowerShell

$env:MNEMONIC='Let us code ICO'; truffle migrate --reset --network ropsten
  • At line:1 char:30 + set MNEMONIC=Let us code ICO && truffle migrate --reset --network ropsten + ~~ The token '&&' is not a valid statement separator in this version. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine – iappmaker Oct 22 '18 at 12:04
  • I have even tried with .env file. please see the edited question – iappmaker Oct 22 '18 at 12:35
  • @iappmaker name of the file should be .env – Aquila Oct 22 '18 at 13:10
  • How about the error returned for this statement "set MNEMONIC=Let us code ICO && truffle migrate --reset --network ropsten" At line:1 char:30 + set MNEMONIC=Let us code ICO && truffle migrate --reset --network ropsten + ~~ The token '&&' is not a valid statement separator in this version. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine – iappmaker Oct 22 '18 at 14:31
  • in PowerShell you need to execute something like: set MNEMONIC='Let us code ICO'; truffle migrate --reset --network ropsten – Aquila Oct 22 '18 at 14:35
0

I think dotenv expects you to have an .env file rather than your envvariable.env file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.