Closed3

storybook-buildが通らない問題

high-ghigh-g

以下のエラーが表示されている

ERR! > const _$$mocks$$ = {};
ERR! | export const $$mock$$ = (name, value) => {
ERR! |   if (typeof _$$mocks$$[name] !== "function") throw new Error("Exported function not found.");
ERR! Module parse failed: Identifier '_$$mocks$$' has already been declared (88:6)
ERR! File was processed with these loaders:
ERR!  * ./node_modules/@storybook/builder-webpack5/node_modules/babel-loader/lib/index.js
ERR!  * ./node_modules/@storybook/source-loader/dist/cjs/index.js
ERR! You may need an additional loader to handle the result of these loaders.
ERR! |   }
ERR! | };
ERR! > const _$$mocks$$ = {};
ERR! | export const $$mock$$ = (name, value) => {
ERR! |   if (typeof _$$mocks$$[name] !== "function") throw new Error("Exported function not found.");
ERR! Module parse failed: Identifier '_$$mocks$$' has already been declared (39:6)
ERR! File was processed with these loaders:
ERR!  * ./node_modules/@storybook/builder-webpack5/node_modules/babel-loader/lib/index.js
ERR!  * ./node_modules/@storybook/source-loader/dist/cjs/index.js
ERR! You may need an additional loader to handle the result of these loaders.
ERR! |   }
ERR! | };
ERR! > const _$$mocks$$ = {};
ERR! | export const $$mock$$ = (name, value) => {
ERR! |   if (typeof _$$mocks$$[name] !== "function") throw new Error("Exported function not found.");
ERR! Module parse failed: Identifier '_$$mocks$$' has already been declared (44:6)
ERR! File was processed with these loaders:
ERR!  * ./node_modules/@storybook/builder-webpack5/node_modules/babel-loader/lib/index.js
ERR!  * ./node_modules/@storybook/source-loader/dist/cjs/index.js
ERR! You may need an additional loader to handle the result of these loaders.
ERR! |   }
ERR! | };
ERR! > const _$$mocks$$ = {};
ERR! | export const $$mock$$ = (name, value) => {
ERR! |   if (typeof _$$mocks$$[name] !== "function") throw new Error("Exported function not found.");
ERR! Module parse failed: Identifier '_$$mocks$$' has already been declared (44:6)
ERR! File was processed with these loaders:
ERR!  * ./node_modules/@storybook/builder-webpack5/node_modules/babel-loader/lib/index.js
ERR!  * ./node_modules/@storybook/source-loader/dist/cjs/index.js
ERR! You may need an additional loader to handle the result of these loaders.
ERR! |   }
ERR! | };
ERR! > const _$$mocks$$ = {};
ERR! | export const $$mock$$ = (name, value) => {
ERR! |   if (typeof _$$mocks$$[name] !== "function") throw new Error("Exported function not found.");
ERR! Module parse failed: Identifier '_$$mocks$$' has already been declared (3:6)
ERR! File was processed with these loaders:
ERR!  * ./node_modules/@storybook/builder-webpack5/node_modules/babel-loader/lib/index.js
ERR! You may need an additional loader to handle the result of these loaders.
ERR! | var _$$mocks$$;
ERR! | import '@storybook/react';
ERR! > const _$$mocks$$ = {};
ERR! | export const $$mock$$ = (name, value) => {
ERR! |   if (typeof _$$mocks$$[name] !== "function") throw new Error("Exported function not found.");
info => Manager built (19 s)
ERR! Error: => Webpack failed, learn more with --debug-webpack
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/@storybook/builder-webpack5/dist/cjs/index.js:234:62
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/HookWebpackError.js:68:3
ERR!     at Hook.eval [as callAsync] (eval at create (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
ERR!     at Cache.shutdown (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Cache.js:150:23)
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:1229:15
ERR!     at Hook.eval [as callAsync] (eval at create (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
ERR!     at Compiler.close (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:1222:23)
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/@storybook/builder-webpack5/dist/cjs/index.js:233:20
ERR!     at finalCallback (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:441:32)
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:458:13
ERR!     at Hook.eval [as callAsync] (eval at create (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:23:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
ERR!     at onCompiled (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:456:21)
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:1200:17
ERR!     at eval (eval at create (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
ERR!     at processTicksAndRejections (node:internal/process/task_queues:96:5)
ERR!  Error: => Webpack failed, learn more with --debug-webpack
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/@storybook/builder-webpack5/dist/cjs/index.js:234:62
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/HookWebpackError.js:68:3
ERR!     at Hook.eval [as callAsync] (eval at create (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
ERR!     at Cache.shutdown (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Cache.js:150:23)
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:1229:15
ERR!     at Hook.eval [as callAsync] (eval at create (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
ERR!     at Compiler.close (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:1222:23)
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/@storybook/builder-webpack5/dist/cjs/index.js:233:20
ERR!     at finalCallback (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:441:32)
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:458:13
ERR!     at Hook.eval [as callAsync] (eval at create (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:23:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
ERR!     at onCompiled (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:456:21)
ERR!     at /Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/lib/Compiler.js:1200:17
ERR!     at eval (eval at create (/Users/tani.fumiya/www/lancers/frontend/header/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
ERR!     at processTicksAndRejections (node:internal/process/task_queues:96:5)
info => Loading presets
error Command failed with exit code 1.
high-ghigh-g

babel-loaderの不一致かも
プロジェクトのpackage.json
"babel-loader": "^9.1.3",

/node_modules/@storybook/builder-webpack5/package.json
"babel-loader": "^8.0.0",

high-ghigh-g

babelrcを以下にしたらokだった

module.exports = {
  presets: [
    '@babel/preset-typescript',
    '@babel/preset-env',
    ['@babel/preset-react', { runtime: 'automatic' }],
  ],
  plugins: ['@emotion/babel-plugin'],
};

このスクラップは2023/11/01にクローズされました