Backstage: yarn create-plugin fails due to missing peer dependencies

Created on 17 Apr 2020  ยท  5Comments  ยท  Source: backstage/backstage

Expected Behavior

Following the guide:

npx @backstage/cli create-app

Followed by:

yarn create-plugin

Would ideally work without extra steps or maybe have extra steps being documented.

Current Behavior

$ npx @backstage/cli create-app

? Enter a name for the app [required] test

Creating the app...

 Checking if the directory is available:
  checking      test โœ” 

 Creating a temporary app directory:
  creating      temporary directory โœ” 

 Preparing files:
  copying       README.md โœ” 
  copying       lerna.json โœ” 
  copying       tsconfig.json โœ” 
  copying       .eslintrc.js โœ” 
  templating    package.json.hbs โœ” 
  copying       prettier.config.js โœ” 
  templating    package.json.hbs โœ” 
  copying       tsconfig.json โœ” 
  copying       android-chrome-192x192.png โœ” 
  copying       favicon-16x16.png โœ” 
  copying       favicon.ico โœ” 
  copying       apple-touch-icon.png โœ” 
  copying       robots.txt โœ” 
  copying       index.html โœ” 
  copying       favicon-32x32.png โœ” 
  copying       manifest.json โœ” 
  copying       safari-pinned-tab.svg โœ” 
  copying       index.tsx โœ” 
  copying       App.tsx โœ” 
  copying       plugins.ts โœ” 
  copying       setupTests.ts โœ” 
  copying       App.test.tsx โœ” 
  copying       README.md โœ” 
  templating    package.json.hbs โœ” 
  copying       tsconfig.json โœ” 
  copying       index.ts โœ” 
  copying       setupTests.ts โœ” 
  copying       plugin.test.ts โœ” 
  copying       plugin.ts โœ” 
  copying       WelcomePage.test.tsx โœ” 
  copying       index.ts โœ” 
  copying       WelcomePage.tsx โœ” 
  copying       index.ts โœ” 
  copying       Timer.tsx โœ” 

 Moving to final location:
  moving        test โœ” 

 Building the app:
  executing     yarn install โœ” 
  executing     yarn build โœ” 

๐Ÿฅ‡  Successfully created test

$ cd test
$ yarn create-plugin  
yarn run v1.22.0
$ backstage-cli create-plugin
? Enter an ID for the plugin [required] sample-plugin

Creating the plugin...

 Checking if the plugin ID is available:
  checking      sample-plugin โœ” 

 Creating a temporary plugin directory:
  creating      temporary directory โœ” 

 Preparing files:
  copying       .eslintrc.js โœ” 
  templating    README.md.hbs โœ” 
  templating    package.json.hbs โœ” 
  copying       tsconfig.json โœ” 
  templating    plugin.test.ts.hbs โœ” 
  templating    plugin.ts.hbs โœ” 
  copying       index.ts โœ” 
  copying       setupTests.ts โœ” 
  templating    ExampleFetchComponent.test.tsx.hbs โœ” 
  templating    ExampleFetchComponent.tsx.hbs โœ” 
  copying       index.ts โœ” 
  templating    ExampleComponent.test.tsx.hbs โœ” 
  templating    ExampleComponent.tsx.hbs โœ” 
  copying       index.ts โœ” 

 Moving to final location:
  moving        sample-plugin โœ” 

 Building the plugin:
  executing     yarn install โœ” 
  executing     yarn build โ—œ 
Error: src/components/ExampleFetchComponent/ExampleFetchComponent.tsx:25:19 - error TS2307: Cannot find module '@material-ui/lab/Alert'.

25 import Alert from '@material-ui/lab/Alert';
                     ~~~~~~~~~~~~~~~~~~~~~~~~
src/components/ExampleFetchComponent/ExampleFetchComponent.tsx:26:26 - error TS2307: Cannot find module 'react-use'.

26 import { useAsync } from 'react-use';
                            ~~~~~~~~~~~


error Command failed with exit code 1.
$ backstage-cli plugin:build
[build-cache] input directory is dirty, skipping cache
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  executing     yarn build โœ– 

Could not execute command yarn build

It seems that something went wrong when creating the plugin ๐Ÿค”
We are going to clean up, and then you can try again.

 Cleanup:
  remove        temporary directory โœ” 

๐Ÿ”ฅ  Failed to create plugin!

โœจ  Done in 21.59s.

Possible Solution

Perhaps make the peer dependencies dev dependencies for the sake of a smooth experience for the Getting Started Guide or perhaps provide a step to install the dependencies in the app before running the create plugin command.

Steps to Reproduce (for bugs)

  1. npx @backstage/cli create-app
  2. cd to the new app directory
  3. yarn create-plugin

Context

I was trying to add a new plugin in a backstage app that I created.

Your Environment

 System Software Overview:

      System Version: macOS 10.15.2 (19C57)
      Kernel Version: Darwin 19.2.0

node --version                        
v12.15.0

yarn --version
1.22.0
bug

All 5 comments

I'm happy to contribute a fix here if it's determined one is needed.

@ruairitobrien, thanks for reporting the issue!

The fix we'd aim for right now is actually to get rid of all peer dependencies, as they don't work particularly well together yarn workspaces. That is, move all peerDependencies to just dependencies, and remove any duplicate devDependencies. Wanna take a shot at that? :grin:

Will do. Thanks!

Just to let you know, will likely be later today/tonight before I can get to it but will do it today! :)

Fixed by #581

Was this page helpful?
0 / 5 - 0 ratings