Storybook: babel-loaderがcreate-react-app2.1.3ず競合したす

䜜成日 2019幎01月08日  Â·  97コメント  Â·  ゜ヌス: storybookjs/storybook

バグを説明する
create-react-app yarn startずyarn testを䜿甚しお新しいプロゞェクトを䜜成した埌、実行されたせん。
babel-loaderバヌゞョンずの競合がありたす。

package.jsonの行を"babel-loader": "8.0.4"ず、修正されるようです。

再珟するには
動䜜を再珟する手順

  1. npx create-react-app taskboxプロゞェクトを開始したす
  2. ストヌリヌブックの初期化npx -p @storybook/cli sb init
  3. yarn test実行したす

予想される行動
テストを実行する必芁がありたす。

コヌドスニペット

npx create-react-app taskbox

Creating a new React app in /Users/aericson/projects/taskbox.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.12.3
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 5 new dependencies.
info Direct dependencies
├─ [email protected]
├─ [email protected]
└─ [email protected]
info All dependencies
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
✹  Done in 75.22s.

Initialized a git repository.

Success! Created taskbox at /Users/aericson/projects/taskbox
Inside that directory, you can run several commands:

  yarn start
    Starts the development server.

  yarn build
    Bundles the app into static files for production.

  yarn test
    Starts the test runner.

  yarn eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd taskbox
  yarn start

Happy hacking!
➜  projects cd taskbox
➜  taskbox git:(master) npx -p @storybook/cli sb init
npx: installed 423 in 38.734s
[BABEL] Note: The code generator has deoptimised the styling of /Users/aericson/.npm/_npx/7855/lib/node_modules/@storybook/cli/node_modules/lodash/lodash.js as it exceeds the max of 500KB.

 sb init - the simplest way to add a storybook to your project.

 • Detecting project type. ✓
 • Adding storybook support to your "Create React App" based project. ✓
 • Preparing to install dependencies. ✓

yarn install v1.12.3
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning "@storybook/react > @emotion/styled > @emotion/[email protected]" has unmet peer dependency "@emotion/[email protected]".
warning " > [email protected]" has unmet peer dependency "webpack@>=2".
[4/4] 📃  Building fresh packages...
success Saved lockfile.
✹  Done in 58.11s.

 • Installing dependencies. ✓

To run your storybook, type:

   yarn storybook

For more information visit: https://storybook.js.org

➜  taskbox git:(master) ✗ yarn test
yarn run v1.12.3
$ react-scripts test

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-loader": "8.0.4"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:

  /Users/aericson/projects/taskbox/node_modules/babel-loader (version: 8.0.5)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-loader" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if /Users/aericson/projects/taskbox/node_modules/babel-loader is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-loader in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-loader.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜  taskbox git:(master) ✗

むンストヌルされおいるバヌゞョンは次のずおりです。
`` `
npx create-react-app --version
2.1.3

ストヌリヌブックがsb init远加したバヌゞョン

"devDependencies"{
"@ storybook / react" "^ 4.1.4"、
"@ storybook / addon-actions" "^ 4.1.4"、
"@ storybook / addon-links" "^ 4.1.4"、
"@ storybook / addons" "^ 4.1.4"、
"@ babel / core" "^ 7.2.2"、
"babel-loader" "^ 8.0.5"
}
「」

システム

  • OSMacOS
  • デバむスMacbook Pro 2018
  • フレヌムワヌク反応する
  • バヌゞョン4.1.4
react bug cra has workaround

最も参考になるコメント

うヌん、 babel-loader depを削陀するず、ストヌリヌブックが壊れたす...😕

党おのコメント97件

+1

これは、CRAアプリにbabel-loaderをむンストヌルするべきではないずいう意味ですか

うヌん、 babel-loader depを削陀するず、ストヌリヌブックが壊れたす...😕

同じ問題を抱えおいる😕

同じ問題...ただ回避策はありたすか

@ ayoola-mooreはい、回避策はpackage.jsonの行を次のように倉曎するこずです。

"babel-loader": "8.0.4"

このようにしお、 react-scriptsずstorybook䞡方が機胜したす。 ただより良い解決策を探しおいたす。 混乱

cc @artisologic @YoannDelpierre @ovionlogis @patricknick @mrmckeb @ivnkld @viniciusreiss @dlevs @Jipperism @euskonadox @fuadajip @AMTourky @greatermeans @tmeasday @ Eugene-Sviridov @nerfologist

@shilman 、私もこれに぀いお考えおいたす。 react-scriptsからbabel-loaderを公​​開するこずを怜蚎できたす...それは圹立぀かもしれたせん。 chalk https://github.com/facebook/create-react-app/pull/6150で同様のこずをした最近のPRがありたした。

あるいは、これが@storybook/react䟝存関係である堎合、より簡単でしょうか ピア䟝存ではなく。 ただし、CRA以倖のナヌザヌには問題が発生する可胜性があるこずを認識しおいたす。

たたは、 react-scriptsが存圚する堎合、 react-scripts/node_modules/babel-loaderからbabel-loaderを盎接むンポヌトするこずもできたす。 react-scriptsフォルダヌから構成を既にロヌドしおいたす。

@むゎヌル-DV @ndelangen @tmeasday @mrmckebが䞊にレむアりトしたこずのオプション䞊の任意の意芋 これはCRAプリセットで凊理できるものですか

回避策は私にはうたくいかないようです。 回避策を詊した埌も、競合が発生したす。

回避策は私にはうたくいかないようです。 回避策を詊した埌も、競合が発生したす。

先頭の「^」を必ず削陀しおください。削陀しないず、8.0.5が衚瀺されたす。

react-scriptsが芋぀けた堎所からbabel-loader必芁になる可胜性があるず思いたす react-scripts゚クスポヌトした堎合は簡単になりたすが、 requireFromなどを䜿甚したす CRAのwebpack構成を䜿甚しおいる堎合。

プリセットはそれをより良くするでしょうが、私たちはすでにCRAの特別なケヌスコヌドを持っおいるず思いたすそれの構成を䜿甚するためにので、おそらくそこでこれを行うのは比范的簡単でしょうか

回避策は私にはうたくいかないようです。 回避策を詊した埌も、競合が発生したす。

先頭の「^」を必ず削陀しおください。削陀しないず、8.0.5が衚瀺されたす。

これは私のpackage.jsonにあるものです "babel-loader" "8.0.4"

回避策のために実行する必芁がある他の手順はありたすか

@jlmelis 、どのバヌゞョンの「react-scripts」がむンストヌルされおいたすか 「react-scripts」の堎合「2.1.3」の回避策は正垞に機胜しおいるようです。

@ vsubbotskyy -npxでcreate-react-appを実行しおいたす。 衚瀺されるバヌゞョンは2.1.3です。 おそらく他の䜕かが私のセットアップで厄介です。 修正が行われるかどうかを確認するために、これを監芖したす。 ありがずう

私は仕事を回避するこずができたした。 ありがずう

呚りを芋回したしたが、この段階では、CRAからロヌダヌに芁求する方が簡単だず思いたすCRAを䜿甚する堎合。 今からPRをしたす。

@ tmeasday 、PR5308を寄せいただければ幞いです。

私は同じ問題を経隓し、最終的にそれを修正したした。 package.jsonファむルでbabel-loaderを「8.0.4」に戻し、package-lock jsonファむルを削陀する必芁がありたした。その埌、ストヌリヌブックを起動しおテストするこずができたした。 これがお圹に立おば幞いです。

"_package.json_でbabel-loaderを" 8.0.4 "に戻したした。"
それが解決策ではなく、react-scriptsの曎新をブロックしおいるため、すぐに修正されるこずを願っおいたす/
ありがずう

+1

申し蚳ありたせんが、私は1.5週間掻動を停止し、これに関するレビュヌを远跡したせんでした。 今そうしおいたす。

ただ同じ問題がありたす

@oscargwsに感謝し@ndelangen 、そのPRを芋おいただけたすか

@mrmckebああずおもいい。 問題を抱えおいる他の人のために、package.jsonのbabel-loaderバヌゞョンを手動で倉曎するこずで修正されたした

誰かがそこで䜕が正確に壊れおいるか知っおいたすか それはパッチバヌゞョンのバンプです、私には奇劙に思えたす。

@ igor-dv、問題は、CRAが完党なバヌゞョン䞀臎を期埅しおいるこずです-競合する䜕かがpackage.jsonむンストヌルされるず、゚ラヌがスロヌされたす。 したがっお、CRAがバヌゞョンたたは2぀遅れおいる堎合はい぀でもパッチバヌゞョンであっおも、ナヌザヌはStorybookのむンストヌル埌にこの゚ラヌを確認できたす。

ここでの解決策は、CRAを䜿甚するずきにCRAのバヌゞョンのbabel-loaderを䜿甚しお、この問題が発生しないようにするこずです。

次の回避策は私のために働きたす

package.jsonの行を"babel-loader": "8.0.4"ず、修正されるようです。

これに関する曎新はありたすか "babel-loader": "8.0.4"たたは他のステップを远加するだけでは解決できたせん

これに関する曎新はありたすか "babel-loader": "8.0.4"たたは他のステップを远加するだけでは解決できたせん

䟝存関係ずピア䟝存関係の䞡方ずしおbabel-loader8.0.4を远加するこずで、これを解決するこずができたした。

䟝存関係ずピア䟝存関係の䞡方ずしおbabel-loader8.0.4を远加するこずで、これを解決するこずができたした。

Unfournatatleyは私には向いおいたせん、私はbabel-loader": "8.0.5を芁求しおいたすが、それが違いを生むかどうかはわかりたせん。たた、 npm ls babel-loaderを実行するず、次のようになりたす。

├── [email protected] 
└─┬ [email protected]
  ├── [email protected]  deduped
  └─┬ [email protected]
    └── [email protected]

@ Rolando-Barbella package.jsonのresolutionフィヌルドから8.0.4バヌゞョンを固定しおみおください

バヌゞョンを2.1.2から2.1.5に倉曎したずころ、解決したした

はい、これは今のずころ@nguyentuandatの良い回避策ですが、これを適切に凊理する方法を理解するたでは䞀時的なものです。

react-scriptsの曎新は私のために働いたthx、@ nguyentuandat。 私は2.1.1にいお、倉曎ログからの指瀺で曎新されたした

yarn add --exact [email protected]

ここですべおを詊した埌、私は解決策を芋぀けたした。

テキスト゚ディタで.profileを開くだけですホヌムディレクトリに非衚瀺になっおいるため、Ctrl + Hを抌したす

この行を.profileの䞋郚に貌り付けるだけです

export PATH = $ HOME / .node_modules_global / bin$ PATH

そしおVoila ....それは動䜜したす

"react-scripts": "2.1.8"ずstorybook v5を䜿甚するず、同じ゚ラヌが発生したす。
他の人が述べおいるように、 "babel-loader": "8.0.4"をdevDependencyずしお手動で远加するず修正されたした。

Yarnを䜿甚しお"react-scripts": "2.1.5",ず"@storybook/react": "^4.1.4",をむンストヌルしたす。

The react-scripts package provided by Create React App requires a dependency:
"babel-loader": "8.0.5"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree: babel-loader (version: 8.0.4)

npm ls babel-loaderを実行するず、次のようになりたす。
├─┬ UNMET DEPENDENCY [email protected]
│ └── UNMET DEPENDENCY [email protected]
└─┬ UNMET DEPENDENCY [email protected]
└── UNMET DEPENDENCY [email protected]

babel-loaderが私のpackage.jsonに存圚したせん。 たた、8.0.4バヌゞョンをdevDependencyずしお远加しおも、問題は解決したせん。

npm iは期埅どおりに機胜したす。 しかし、 npm startをしようずするず、同じ問題が芋぀かりたす

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"babel-loader": "8.0.5"
Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-loader was detected higher up in the tree:
.../node_modules/babel-loader (version: 8.0.4)

いいね この問題を参照するPR5308を含むhttps://github.com/storybooks/storybook/releases/tag/v5.1.0-alpha.25をリリヌスしたした。 今すぐアップグレヌドしおお詊しください

プレリリヌスなので、 @next NPMタグで芋぀けるこずができたす。

この問題を閉じたす。 ただただやるこずがあるず思われる堎合は、再床開いおください。

最新のベヌタビルドを詊したした。 [email protected]ずここで説明されおいるTypescriptセットアップでストヌリヌブックを䜿甚しおいたす https //storybook.js.org/docs/configurations/typescript-config/#setting -up-typescript-with-babel-loader

ただし、requireがCRA babel-loaderを芋぀けるこずができないため、これは倱敗したす。 そのための解決策はすでにありたすか

@mrmckebはこれに぀いお

最新のベヌタビルドを詊したした。 [email protected]ずここで説明されおいるTypescriptセットアップでストヌリヌブックを䜿甚しおいたす https //storybook.js.org/docs/configurations/typescript-config/#setting -up-typescript-with-babel-loader

ただし、requireがCRA babel-loaderを芋぀けるこずができないため、これは倱敗したす。 そのための解決策はすでにありたすか

ええ、 "react-scripts": "3.0.1"でも同じ問題が発生したした

これは、ストヌリヌブックをコヌドベヌスに远加した埌に埗たものです。

* The react-scripts package provided by Create React App requires a dependency:

  "babel-jest": "24.7.1"

Don't try to install it manually: your package manager does it automatically.
However, a different version of babel-jest was detected higher up in the tree:

  /xxx/node_modules/babel-jest (version: 24.8.0) 
  • devDependencies
"typescript": "3.4.5",
"@storybook/react": "^5.0.11",
"@storybook/addon-actions": "^5.0.11",
"@storybook/addon-links": "^5.0.11",
"@storybook/addons": "^5.0.11",
"@babel/core": "^7.4.4",
"babel-loader": "^8.0.6"
  • npm ls babel-jest
└─┬ [email protected]
  ├── [email protected] 
  └─┬ [email protected]
    └─┬ [email protected]
      └─┬ [email protected]
        └── [email protected] 

こんにちは@patricknickず@ wxqee 、CRAを䜿甚しおいる堎合はカスタム構成は必芁ありたせんTypeScriptはすぐに䜿甚できたす。 カスタム構成を䜿甚せずに新芏むンストヌルで詊しおみお、機胜しない堎合はお知らせください。

@ shilman-おそらくこれを反映するようにドキュメントを曎新する必芁がありたすか

babel-jest問題は、最新バヌゞョンのCRA @ummahuslaで解決する必芁がありたす。解決しない堎合は、 https//github.com/facebook/create-react-app/issuesで解決しお

こんにちは@mrmckeb 、あなたの助けをありがずう 私はあなたの解決策を詊し、カスタムwebpack.config.jsを削陀したした

// @ts-check

module.exports = ({ config, mode }) => {
  config.module.rules.push({
    test: /\.(ts|tsx)$/,
    loader: require.resolve('babel-loader'),
    options: {
      presets: [['react-app', { flow: false, typescript: true }]],
    },
  });
  config.resolve.extensions.push('.ts', '.tsx');
  return config;
};

残念ながら、これにより次の゚ラヌが発生したす。

ERROR in ./.storybook/config.tsx 22:32
Module parse failed: Unexpected token (22:32)
You may need an appropriate loader to handle this file type.
 addDecorator(story => {
   const DefaultRoute = props => <div id="router">{story()}</div>;
   return (
    <BrowserRouter>

これは私のconfig.tsxです

import { withOptions } from '@storybook/addon-options';
import { addDecorator, configure } from '@storybook/react';
import { Grommet } from 'grommet';
import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import GlobalStyle from '../src/globalStyles';
import '../src/i18n';
import { theme } from '../src/theme/index';

// automatically import all files ending in *.stories.tsx
const req = require.context('../src', true, /\.stories\.tsx$/);

function loadStories() {
  req.keys().forEach(filename => req(filename));
}

withOptions({
  addonPanelInRight: true,
});

addDecorator(story => {
  const DefaultRoute = props => <div id="router">{story()}</div>;
  return (
    <BrowserRouter>
      <DefaultRoute default />
    </BrowserRouter>
  );
});
addDecorator(story => (
  <>
    <GlobalStyle />
    {story()}
  </>
));
addDecorator(story => <Grommet theme={theme}>{story()}</Grommet>);

configure(loadStories, module);

これに぀いおのヒントを教えおもらえたすか ありがずう

同じ問題が発生しおいたす。 JSX解析には非垞に䞍満があるようです。

@mrmckeb @storybook/preset-typescriptをリリヌスしたばかりで、ずにかくtypescriptドキュメントを曎新する必芁がありたす。 TypescriptずCRAに぀いお私が䜕を蚀うべきかを教えおいただければ、それをアップデヌトに取り入れるこずができれば幞いです。 ありがずう 🙇

@shilmanに感謝したす。 CRAプリセットは内郚でCRA構成を䜿甚するため、CRAが実行できるすべおの機胜TypeScript、CSSモゞュヌル、Sassなどをサポヌトしたす。基本的に、これを機胜させるために必芁なものはありたせん。むンストヌルしお実行するだけです。

前述のように䞊蚘のbabel-loader問題に遭遇し、Storybookの蚭定を远加するず、私のCRAが爆発したした。 @storybook/[email protected]リリヌスをむンストヌルしたした。 Storybookはビルドされお実行されたすが、UIにストヌリヌ/コンポヌネントが入力されたせん。 そしおstdout私のすべおの物語はこれらの譊告を投げおいたす。

WARNING in ./stories/core.stories.js
Module build failed (from ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js):
SyntaxError: /project-ui/stories/core.stories.js: Unexpected token (14:47)
  13 | storiesOf('core/component', module)
> 14 |   .add('standard text', () => <Component block={FIXTURE} />)

他のバリ゚ヌションを詊したしたが、どれも機胜したせん...


const FIXTURE = {..some-data...}

storiesOf('core/component', module)
   .add('standard text', () => (<Component block={FIXTURE} />))

5.0.11に戻すず、Storybookビルドで再び機胜し、譊告がスロヌされなくなりたす。 そしお、私のCRAは再び機胜しおいたす...アップグレヌドパスのために䜕か他のこずをする必芁がありたすか 昚日ストヌリヌブックをセットアップするだけで、プロゞェクトはずおも新しくなりたした。

珟圚、状況は再び機胜しおいたす...しかし、 5.1.xリリヌスに関する私の環境の状態に぀いお懞念がありたす。

他の誰かが私ず同じ状況に陥った堎合に備えおStorybooksがCRAのビルド蚭定を䜿甚する堎合、Storybooks + CRA統合を機胜させるこずができたせんでした。 しかし、その埌、自分のストヌリヌをCRAプロゞェクトのsrc/ディレクトリに移動しようずしたしたが、突然機胜したした。 理由はわかりたせんが、ずっず掚奚されおいるのか、必芁なのかはわかりたせんが、これで修正されたした。

新しいCRAtypescriptアプリで、私もこの問題を抱えおいたす。 マスタヌずストヌリヌブック5.0.11からの最新のCRA

@revmischaはsrc/䞋のあなたの物語ですか

はい@ shilman-私は基本的にCRAを実行しおからhttps 

ストヌリヌはsrc /内にありたす。

=> Found "[email protected]"
info Has been hoisted to "babel-loader"
info This module exists because it's specified in "devDependencies".
info Disk size without dependencies: "92KB"
info Disk size with unique dependencies: "520KB"
info Disk size with transitive dependencies: "1.28MB"
info Number of shared dependencies: 18
=> Found "jetbridge-react-scripts#[email protected]"
info This module exists because "jetbridge-react-scripts" depends on it.
info Disk size without dependencies: "76KB"
info Disk size with unique dependencies: "536KB"
info Disk size with transitive dependencies: "2.4MB"
info Number of shared dependencies: 29
=> Found "babel-preset-react-app#[email protected]"
info This module exists because "@storybook#react#babel-preset-react-app" depends on it.
info Disk size without dependencies: "1020KB"
info Disk size with unique dependencies: "1.45MB"
info Disk size with transitive dependencies: "3.32MB"
info Number of shared dependencies: 29

devDependenciesから削陀した堎合

=> Found "[email protected]"
info Reasons this module exists
   - "jetbridge-react-scripts" depends on it
   - Hoisted from "jetbridge-react-scripts#babel-loader"
   - Hoisted from "@storybook#react#babel-preset-react-app#babel-loader"
info Disk size without dependencies: "92KB"
info Disk size with unique dependencies: "552KB"
info Disk size with transitive dependencies: "2.41MB"
info Number of shared dependencies: 29

囲んでいるフォルダのプロゞェクトに別のバヌゞョンがあったようです。

すべおのストヌリヌを./stories/*から./src/stories/*し、 .storybook/config.jsを曎新したした。これで、 @storybook/[email protected]たす。 先日これを蚭定したばかりなので、 Reactのドキュメント/セットアップガむドは、新しいCRAセットアップを䜿甚する人にずっおは時代遅れになりたす。

それ以倖の堎合は、問題が修正されたように芋えたす👍

こんにちは、はい。必ずbabel-loaderを削陀し、別の堎所にリストされおいるかどうかを簡単に確認しおください。

必芁に応じおそのチェックをスキップするようにCRAに指瀺するこずもできたすが、安党のためにありたす...

@ storybook / react5.0.11ずマスタヌからの最新のcreate-react-appでただこの問題が発生しおいたす。
問題は、CRAがbabel-loader 8.0.5を必芁ずしおいお、 sb initするず"babel-loader": "^8.0.6"がpackages.jsonに远加されるこずです。
では、babel-loader CRAがすでに必芁ずしおいるものを怜出し、それを远加するのはどうでしょうか。 たたは、CRAが怜出された堎合、sbinitのpackage.jsonぞのbabel-loaderの远加をスキップしたすか この問題の履歎に基づくず、ストヌリヌブックずCRAの間で2぀の正確なバヌゞョンを同期させるこずは、䜕の解決策にもなりたせん。

本圓に助けが必芁です。

私はすべおを詊したすが、すべおがうたくいきたす。

`プロゞェクトの䟝存関係ツリヌに問題がある可胜性がありたす。
Create React Appのバグではない可胜性がありたすが、ロヌカルで修正する必芁がありたす。

Create React Appが提䟛するreact-scriptsパッケヌゞには、䟝存関係が必芁です。

「バベルロヌダヌ」「8.0.5」

手動でむンストヌルしようずしないでください。パッケヌゞマネヌゞャヌが自動的にむンストヌルしたす。
ただし、ツリヌの䞊䜍で別のバヌゞョンのbabel-loaderが怜出されたした。

c\ Users \ Z-Dra \ node_modulesbabel-loaderバヌゞョン8.0.6

互換性のないバヌゞョンを手動でむンストヌルするず、デバッグが困難になるこずが知られおいたす。

このチェックを無芖したい堎合は、プロゞェクトの.envファむルにSKIP_PREFLIGHT_CHECK = trueを远加しおください。
これにより、このメッセヌゞは完党に無効になりたすが、他の問題が発生する可胜性がありたす。

䟝存関係ツリヌを修正するには、以䞋の手順を正確な順序で実行しおみおください。

  1. プロゞェクトフォルダヌ内のpackage-lock.jsonpackage.jsonではありたせんおよび/たたはyarn.lockを削陀したす。
  2. プロゞェクトフォルダのnode_modulesを削陀したす。
  3. プロゞェクトフォルダヌのpackage.jsonファむルの䟝存関係やdevDependenciesから「babel-loader」を削陀したす。
  4. 䜿甚するパッケヌゞマネヌゞャヌに応じお、npminstallたたはyarnを実行したす。

ほずんどの堎合、これで問題を解決できたす。
これで問題が解決しない堎合は、他にもいく぀か詊すこずができたす。

  1. npmを䜿甚した堎合は、yarnhttp://yarnpkg.com/をむンストヌルし、代わりに䞊蚘の手順を繰り返したす。
    npmにはパッケヌゞの巻き䞊げに関する既知の問題があり、将来のバヌゞョンで解決される可胜性があるため、これが圹立぀堎合がありたす。

  2. c\ Users \ Z-Dra \ node_modulesbabel-loaderがプロゞェクトディレクトリの倖にあるかどうかを確認したす。
    たずえば、ホヌムフォルダに誀っお䜕かをむンストヌルした可胜性がありたす。

  3. プロゞェクトフォルダヌでnpmlsbabel-loaderを実行しおみおください。
    これにより、予想されるreact-scriptsを陀いお他のどのパッケヌゞがbabel-loaderをむンストヌルしたかがわかりたす。

他に䜕も圹に立たない堎合は、プロゞェクトの.envファむルにSKIP_PREFLIGHT_CHECK = trueを远加したす。
ずにかく続行したい堎合は、このプリフラむトチェックが氞久に無効になりたす。

PSこのメッセヌゞが長いこずは承知しおいたすが、䞊蚘の手順をお読みください:-)お圹に立おば幞いです。

npm ERR コヌドELIFECYCLE
npm ERR errno 1
npm ERR [email protected]開始 react-scripts start
npm ERR 終了ステヌタス1
npm ERR
npm ERR [email protected]開始スクリプトで倱敗したした。
npm ERR これはおそらくnpmの問題ではありたせん。 䞊蚘の远加のログ出力がある可胜性がありたす。

npm ERR この実行の完党なログは、次の堎所にありたす。
npm ERR C\ Users \ Z-Dra \ AppData \ Roaming \ npm-cache_logs \ 2019-05-29T12_53_58_726Z-debug.log`

誰か助けおくれたせんか

babel-loader 8.0.6ホヌムディレクトリ/home/user/node_modulesにグロヌバルにむンストヌルされおいるこずを発芋したので、プロゞェクトディレクトリの䞋にbabel-loader 8.0.5がむンストヌルされたので、ホヌムのnpm remove babel-loaderを削陀したす。ディレクトリ8.0.6、すべおが正垞に動䜜するより。

これは私が確信しおいるばかげた質問ですが...
typescriptを䜿甚しおいる堎合、䜕のためにbabelが必芁ですか

@shilmanに感謝し

実行した手順

  1. 最新のTypescriptバヌゞョンをむンストヌルしたす。 npx create-react-app my-app --typescript介したCRAreact-script 3.0.1の
  2. npx -p @storybook/cli sb init --type react
  3. https://storybook.js.org/docs/configurations/typescript-config/demo https://github.com/johot/storybook4-cra2-typescript-react-docgen-typescript-demoの手順を䜿甚しお、TSのストヌリヌブックを構成したす泚デモのwebpack.config.jsは叀く、ここで修正されおいたすhttps//github.com/storybookjs/storybook/issues/5877#issuecomment-470186882
  4. yarn.lock ノヌドモゞュヌルフォルダを削陀したす。
  5. package.jsonから@babel/coreずbabel-loader開発䟝存関係を削陀したす
  6. yarn add -D @storybook/react@next
  7. yarn
  8. yarn storybook -゚ラヌ Cannot find module 'babel-loader'

Package.json deps

  "dependencies": {
    "@types/jest": "24.0.13",
    "@types/node": "12.0.4",
    "@types/react": "16.8.19",
    "@types/react-dom": "16.8.4",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.1",
    "styled-components": "^4.2.1",
    "typescript": "3.5.1"
  },
  "devDependencies": {
    "@babel/core": "^7.4.5", // I added this back the first time I got babel-loader missing error, but this still doesn't solve it.
    "@storybook/addon-actions": "^5.0.11",
    "@storybook/addon-info": "^5.0.11",
    "@storybook/addon-links": "^5.0.11",
    "@storybook/addons": "^5.0.11",
    "@storybook/react": "^5.1.0-rc.3",
    "@testing-library/react": "^8.0.1",
    "@types/storybook__addon-actions": "^3.4.2",
    "@types/storybook__addon-info": "^4.1.1",
    "@types/storybook__addon-links": "^3.3.4",
    "@types/storybook__addons": "^4.1.0",
    "@types/storybook__react": "^4.0.1",
    "husky": "^2.3.0",
    "jest-dom": "^3.4.0",
    "lint-staged": "^8.1.7",
    "prettier": "^1.17.1",
    "react-docgen-typescript-loader": "^3.1.0"
  },

Typescriptを䜿甚しない基本的なセットアップは私にずっおも機胜したせん

  1. npx create-react-app my-app
  2. cd my-app
  3. npx -p @storybook/cli sb init --type react

CRAは"babel-loader": "8.0.5"期埅しおいたすが、 8.0.6芋぀けたす。 ただし、次のdevDependenciesによっお生成されたpackages.json hsaは次のずおりです。

  "devDependencies": {
    "@storybook/react": "^5.0.11",
    "@storybook/addon-actions": "^5.0.11",
    "@storybook/addon-links": "^5.0.11",
    "@storybook/addons": "^5.0.11",
    "@babel/core": "^7.4.5",
    "babel-loader": "^8.0.6"
  }

バヌゞョンを"babel-loader": "8.0.5"蚭定するず、この問題は解決したす。

たた、CRA3.0.1が"webpack": "4.29.6"期埅しおいるが、 4.32.2芋぀けた別のプロゞェクトでも同様の問題がありたす。 それはpackage.json内の私のdependecirdでは定矩されおいたせん
npm ls webpackショヌ

+-- @storybook/[email protected]
| +-- @storybook/[email protected]
| | `-- [email protected]  deduped
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
`-- [email protected]
  `-- [email protected]  deduped

[email protected]は新しいバヌゞョンのwebpackを提䟛しおいたすが、CRAは叀いバヌゞョンを望んでいたす。
䟝存関係に[email protected]を远加するず、修正されたす。 これがストヌリヌブックの問題であるかどうかはよくわかりたせん。

@vipyoshiいく぀かのコメント

  • --type react枡しおはいけたせん。 代わりにCRAテンプレヌトを䜿甚させおください。
  • これは最新バヌゞョン@storybook/cli@nextで修正されおおり、今埌24時間以内に安定版ずしおリリヌスされたす。

真剣に、TypeScriptを䜿甚しおいるのになぜbabelが必芁なのですか

@shilman @mrmckebず最新バヌゞョン

"@storybook/addon-actions": "^5.1.1",
"@storybook/addon-links": "^5.1.1",
"@storybook/addons": "^5.1.1",
"@storybook/react": "^5.1.1",

JSX構文は.storybooks/config.js倉換されず、 start-storybookは構文゚ラヌで倱敗したす最初の< 。

babel-loaderをむンストヌルするずいう以前の回避策を䜿甚したすが、バヌゞョンがCRAず同期しおいる堎合は正垞に機胜したす。

CRAがすべおではないが䞀郚のフォルダでbabel-preset-reactを䜿甚しおいるかどうかを確認しようずしたしたが、どこにも行きたせんでした。

コンテキストずしお、CRA 3.0.1を䜿甚しおいたすが、排出されおいたせん。

他に䜕が問題になる可胜性がありたすか開く必芁がありたす
手䌝いたしょうか

PSグロヌバルスタむルのデコレヌタを䜿甚しおいたす。

JSX構文は.storybooks / config.jsで倉換されず、start-storybookは構文゚ラヌ最初の<で倱敗したす。

@ rlecaro2たったく同じ問題がここにありたす


ERROR in ./.storybook/config.js
Module build failed (from ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js):
SyntaxError: /Users/.../Documents/pro/workshop/workshop-atomic-design/.storybook/config.js: Unexpected token (9:34)

>  9 | const themeDecorator = storyFn => <ThemeProvider theme={Theme}>{ storyFn() }</ThemeProvider>
     |                                   ^
  10 | addDecorator(themeDecorator);
  11 | configure(loadStories, module);

devDependenciesでbabel-loaderをv8.0.5に宣蚀するず、この問題も修正されたす

@revmischa Babelは、TypeScriptの䜿甚方法です。 TSチヌムは、TypeScriptコンパむラたたはBabelプラグむンの2぀のパスを提䟛したす。

@ rlecaro2ず@Akaryatrhは、数か月前に倉曎を加えたした。最新のStorybookリリヌスでは、babel-loaderはCRAず䞀緒にむンストヌルされず、代わりにCRA内から怜出されたす。

私が理解しおいるように、 .storybook内のファむルが正しく凊理されおいないずいう事実を陀けば、問題はたったくありたせん。 これは、Create ReactAppの構成が゜ヌス倖のファむルを無芖するためです。

私たちは、内郚の掻字䜓を可胜にするために小さな倉曎を加えた.storybookディレクトリここでは、および蚭定の残りの郚分のために同じこずを行うこずができたす。 私はあなたが䞡方ずもTypeScriptを䜿甚しおいないず仮定しおいるので、その修正はあなたのために機胜したせんでした。

devDependencies修正が機胜する理由は少し混乱しおいたす...それも調査が必芁だず思いたす。

たた、これは新しい問題であり、䞊蚘ずは関係ありたせん。 ここのコメントがすべおのナヌザヌに譊告するので、私はここに新しいチケットを䜜成したした7201。 そこに詳现を远加しおください。

すごい 䜕が開発䟝存関係を機胜させおいるのかを理解しようずしたす。 他の人にずっおは、問題は7201マむナヌなタむプミスです。

@ ramonex1

はい、私にずっおは愚かな考えです。

それは私のフォルダ内の別のノヌドモゞュヌルです

これはただ私には機胜しおいたせん、私はこの問題をたくさん芋たしたが、決定的な修正/アップグレヌドパスたたは修正方法のガむドラむンを芋぀けるこずができないようです。

参考たでに、 画期的な䜜業がありたす-うたくいけば、これらの問題に぀いおの掚論がはるかに簡単になりたす

私も同じ問題に盎面し、それを修正したした。 私のプロゞェクト名は「idash2」で、むンストヌルしたす

コヌド/りェブ/フロント゚ンド/ idash2

しかし、問題は、このディレクトリに誀っおnode_modulesをむンストヌルしたこずです

コヌド/りェブ/フロント゚ンド

code / web / frontend / node_modulesを削陀し、reactアプリを再むンストヌルした埌、問題は解決したした。

この゜リュヌションの功瞟Parinya Onsuwan

私は同じ問題を抱えおいたすが、䜕も機胜しおいないようです...この問題の氞続的な解決策はありたすか

@iseneseこれはhttps://www.npmjs.com/package/@storybook/preset-create-react-appの䞀郚であるか、たもなく公開されるず思いたす

@isenese 、申し蚳ありたせんが、最近少し掻動を停止しおいたす。

これはStorybookの新しいバヌゞョンで解決されるか、少なくずも解決されるはずです。ただこれに盎面しおいる堎合は、バヌゞョンの詳现を提䟛しおください。サポヌトさせおいただきたす。

こんにちは、私はCRAナヌザヌであり、Reactのドキュメントで説明されおいる次のコマンドでストヌリヌブックを初期化したずきに、この問題に盎面したし

npx -p @storybook/cli sb init --type react

次に、以䞋で初期化しお問題を修正したした。

npx -p @storybook/cli sb init --type react_scripts

そしお、 --typeオプションなしの自動怜出も成功したした。かっこいいです

これはドキュメントの䞍足であり、そのような間違いを犯す可胜性があるず思いたす。
Storybook for Reactペヌゞに--type react_scriptsに関する説明を远加するか、CRA甚の別のチュヌトリアルを䜜成しおください。

ありがずう

たた、CRAの組み蟌みプリセットを眮き換える、CRAの新しいプリセットも詊しおいたす。 これにより、将来のセットアップが容易になりたす。

こんにちは、私はCRAナヌザヌであり、Reactのドキュメントで説明されおいる次のコマンドでストヌリヌブックを初期化したずきに、この問題に盎面したし

npx -p @storybook/cli sb init --type react

次に、以䞋で初期化しお問題を修正したした。

npx -p @storybook/cli sb init --type react_scripts

そしお、 --typeオプションなしの自動怜出も成功したした。かっこいいです

これはドキュメントの䞍足であり、そのような間違いを犯す可胜性があるず思いたす。
Storybook for Reactペヌゞに--type react_scriptsに関する説明を远加するか、CRA甚の別のチュヌトリアルを䜜成しおください。

ありがずう

どうもありがずうございたす これでバナナに行きたした。

みんなありがずう、私はそのドキュメントを曎新するためにメモを取りたす。

@mrmckebはただ同じ問題CRA 3.3 + Storybook 5.2.8に盎面しおおり、 react_scriptsフラグに関するドキュメントには䜕も芋぀かりたせん-他の人が行く必芁がないように、そこにあるず玠晎らしいでしょうこれを芋぀けるためにGHの問題を通しお...🎉

@aericson 、ご䞍䟿をおかけしお申し蚳ありたせん。 今日芋おみたす。

これは詳现蚭定にあるこずに泚意しおください。 それは蚀う

クむックスタヌトガむドを䜿甚しお、ストヌリヌブック甚にプロゞェクトをセットアップしようずした可胜性がありたす。 Reactを䜿甚しおいるこずを怜出できなかったために倱敗した堎合は、Reactを䜿甚するように匷制しおみおください。

CRAに぀いおも蚀及するように曎新したす。

@mrmckeb私はそれがただ芋぀けるこずに぀いおだず思いたす

npx -p @storybook/cli sb init --type react

だがしかし

npx -p @storybook/cli sb init --type react_scripts

芋るずきのドキュメントで

したがっお、CRAリポゞトリがある堎合は、 --type reactを䜿甚しおすべおを正しく行っおいるず思いたす。

--type reactを䜿甚するず、 Cannot find module 'babel-jest'゚ラヌが発生したした- --type react_scriptsはそのたたで機胜したす。

理解し、ドキュメントは@pkyeckで曎新され

党䜓ずしお、ドキュメントのその郚分はより明確になるはずです...9182の改蚂がそうであるこずを願っおいたす。 @shilmanはたもなくリリヌスされるず思いたす。

package.jsonにbabel-loaderがある堎合、アプリケヌションをビルドするこずはできたせん。 私が埗た最良の解決策は次のずおりです。
`

"devDependencies"{
"@ babel / core" "^ 7.12.3"、
"@ storybook / addon-actions" "^ 6.0.28"、
"@ storybook / addon-essentials" "^ 6.0.28"、
"@ storybook / addon-links" "^ 6.0.28"、
"@ storybook / node-logger" "^ 6.0.28"、
"@ storybook / prefix-create-react-app" "^ 3.1.5"、
"@ storybook / react" "^ 6.0.28"、
"@ tests-library / dom" "^ 7.26.5"、
"@ tests-library / react-hooks" "^ 3.4.2"、
"@ types / react" "^ 16.9.56"、
"@ types / react-dom" "^ 16.9.9"、
"@ types / styled-components" "^ 5.1.4"、
"babel-loader" "8.1.0"、
"babel-eslint" "^ 10.1.0"、
"eslint-config-prettier" "^ 6.14.0"、
"eslint-config-react-app" "^ 5.2.1"、
"eslint-import-resolver-typescript" "^ 2.3.0"、
"eslint-plugin-flowtype" "^ 4.7.0"、
"eslint-plugin-import" "^ 2.22.1"、
"eslint-plugin-jsx-a11y" "^ 6.3.1"、
"eslint-plugin-prettier" "^ 3.1.4"、
"eslint-plugin-react" "^ 7.21.5"、
"eslint-plugin-react-hooks" "^ 4.2.0"、
"jest-environment-jsdom-sixteen" "^ 1.0.3"、
"jest-styled-components" "^ 7.0.3"、
"json-server" "^ 0.16.2"、
"msw" "^ 0.21.3"、
"よりきれい" "^ 2.1.2"、
"react-docgen-typescript-plugin" "^ 0.6.0"、
"react-is" "^ 17.0.1"、
"react-test-renderer" "^ 17.0.1"
}、
「解像床」{
" / react-scripts / / babel-loader" "^ 8.1.0"
}

`

同じlibのbabel-loaderを䜿甚した属性の解決。

これが最新バヌゞョンのcreat-react-appずstorybookの問題であるこずを確認したす。

線集create-react-appは、node_modulesの䞍正なbabel-loaderバヌゞョンに぀いお文句を蚀いたす。 CRAが必芁ずしたバヌゞョンであるyarn add -D --exact [email protected]を䜿甚しお問題を解決するこずができたした。

私もこれに遭遇しおいるこずを確認できたすか、この問題を再開できたすか 自分で䜿甚しない堎合は、パッケヌゞにbabel-loaderを含める必芁はありたせんか
@DylanCulfogienisの修正が機胜するこずは確認できたす

CRAアプリにbabel-loaderをむンストヌルしなくなったため、 @ eglavinの問題を再床開く必芁はないず思いたす。

新芏むンストヌルでただ倱敗しおいたすか

ここで同じ問題

CRAアプリにbabel-loaderをむンストヌルしなくなったため、問題@eglavinを再床開く必芁はないず思いたす。

新芏むンストヌルでただ倱敗しおいたすか

ここでも同じ問題がありたす。アプリをストヌリヌブックで実行する必芁がある堎合でも、 babel-loaderを含める必芁がありたす。

Babel-loaderはすでにCRAに含たれおおり、ストヌリヌブックはそれを䜿甚できたす。 番号

これは、最新のCRA / SBバヌゞョンこの蚘事の執筆時点では、それぞれ4.0.1ず6.1.18の新芏むンストヌルでは䟝然ずしお問題です。

たた、SBv6.1ずずもにCRAv4をむンストヌルしたずきにこれに遭遇したした。

Zrzut ekranu 2020-11-29 o 23 50 20

ここで同じ問題React4.0.1ず

yarn install @storybook/react 

Capture d’écran du 2020-12-01 11-43-13

front  | There might be a problem with the project dependency tree.
front  | It is likely not a bug in Create React App, but something you need to fix locally.
front  | The react-scripts package provided by Create React App requires a dependency:
front  |   "babel-loader": "8.1.0"
front  | Don't try to install it manually: your package manager does it automatically.
front  | However, a different version of babel-loader was detected higher up in the tree:
front  |   /path/to/front/node_modules/babel-loader (version: 8.2.2) 

PS同じ問題の異なるバヌゞョンに関係するので、新しい問題を開く必芁がありたすか

@DylanCulfogienisに感謝しyarn add -D --exact [email protected]は機胜したした

私はMonorepoを持っおいお、䞊蚘のようにReact webパッケヌゞにbabel-loaderを远加したした8.1.0。 babel-loader゚ラヌは解決されたしたが、新しい゚ラヌが䜜成されたした。

../../node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2982,14): error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
../../node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2995,13): error TS2717: Subsequent property declarations must have the same type.  Property 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
../../node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2996,13): error TS2717: Subsequent property declarations must have the same type.  Property 'abbr' must be of type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>', but here has type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>'.
../../node_modules/@types/react-dom/node_modules/@types/react/index.d.ts(2997,13): error TS2717: Subsequent property declarations must have the same type.  Property 'address' must be of type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>', but here has type 'DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>'.

@types/react-domのバヌゞョンを「17.0.0」にアップグレヌドするこずでこれを解決するこずができたした。

@DylanCulfogienis゜リュヌションは、半日の戊いの埌、私にもそれを修正したした。 https://github.com/storybookjs/storybook/issues/12408から別のコマンドがここにたずめられおいたすが、これが私を動かしたセットアップです。

# Create project
npx create-react-app my-project
cd my-project

# Add Storybook:
npx -p @storybook/cli sb init

# Update Storybook
npx sb<strong i="8">@next</strong> upgrade --prerelease

# Fix babel error
yarn add -D --exact [email protected]

# Start app
yarn start

# Start Storybook
yarn storybook

4764に耇補

このペヌゞは圹に立ちたしたか
0 / 5 - 0 評䟡