Amplify-cli: init failed TypeError: Cannot read property 'configLevel' of undefined

Created on 23 Sep 2019  路  7Comments  路  Source: aws-amplify/amplify-cli

Amplify CLI version:
3.9.0

Platform:
Windows 10

When trying to create an new environment (with a name that I've used before but have removed since), it fails with the following issue.

amplify env add
? Do you want to use an existing environment? No
? Enter a name for the environment dev
Using default provider  awscloudformation
init failed
TypeError: Cannot read property 'configLevel' of undefined
    at getAwsConfig (C:\Users\Andrew\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\lib\initializer.js:65:21)
    at Object.run (C:\Users\Andrew\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\lib\initializer.js:44:29)
    at process._tickCallback (internal/process/next_tick.js:68:7)
pending-triage platform

Most helpful comment

Found a lingering environment setting <my old env name> in the amplify/.config/local-aws-info.json. It must've been left behind due to a inconsistent environment removal.

The fix was to remove the <your old env name> environment block in your amplify/.config/local-aws-info.json. then add the environment of the same name again with amplify env add.

All 7 comments

Hi @andrew-aernos

What's the Operating system you ran the amplify cli on?
could you also run amplify -v and find out the version of the cli?

Hi @andrew-aernos

What's the Operating system you ran the amplify cli on?
could you also run amplify -v and find out the version of the cli?

Amplify CLI version: 3.9.0
Platform: Windows 10

Strangely, I can add another environment with the name 'prod' for production.

I think it may have to do with having an environment named 'dev' before. I removed the dev environment some time ago with amplify env remove dev when I merged changes to master , but maybe some residue stuff left hanging around?

When I list the environments with
amplify env list, dev isn't listed.

Found a lingering environment setting <my old env name> in the amplify/.config/local-aws-info.json. It must've been left behind due to a inconsistent environment removal.

The fix was to remove the <your old env name> environment block in your amplify/.config/local-aws-info.json. then add the environment of the same name again with amplify env add.

not sure what was the cause of the incomplete env removal. I tested and the environment is actually removed from the amplify/.config/local-aws-info.json file.
Could you try a amplify env remove again and see if you still have the incomplete env removal?

I couldn't reproduce my issue after I manually removed the offending environment from the local-aws-info.json.

Not sure what caused it in the first place, I did find left-over 'dev' stack on the cloud along with its resources. probably a stupid/impatient me terminated the process while roll-back was in place and the local-aws-info.json wasn't updated (??).

As of now I tried amplify env remove <myenv> and it does remove the environment from the local-aws-info.json as expected.

@UnleashedMind I experienced the exact same issue. I tried running amplify env remove staging again as you suggested (staging being the name of the environment in my case) and I received the response No environment found with the corresponding name provided. So just like @andrew-aernos I had to manually delete the entry in my local-aws-info.json file.

In my case, staging was an environment that had been deleted a few months ago, definitely with a previous version of the Amplify CLI though I don't remember what version at the time.

Was this page helpful?
0 / 5 - 0 ratings