Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory for storybook-init-framework-entry.js, preview.js-generated-config-entry.js and generated-stories-entry.js #12864

Closed
Noldaru opened this issue Oct 22, 2020 · 10 comments

Comments

@Noldaru
Copy link

Noldaru commented Oct 22, 2020

[Support] No such file or directory error for unknown config files on build

I am attempting to upgrade from storybook version 5.2 to 6.x, but am getting several errors for files that do no exist in my .storybook folder after the build, namely storybook-init-framework-entry.js, preview.js-generated-config-entry.js and generated-stories-entry.js

I can find no reference to any of these files nor make out their purpose in the documentation, nor was I able to find any other issues involving missing config files.

Steps to reproduce

Update storybook

npx sb upgrade

Attempt to build storybook:

start-storybook -p 7001

Please specify which version of Storybook and optionally any affected addons that you're running

  • @storybook/addon-a11y 6.0.26
  • @storybook/addon-actions 6.0.26
  • @storybook/addon-backgrounds 6.0.26
  • @storybook/addon-console 1.2.2
  • @storybook/addon-docs 6.0.26
  • @storybook/addon-jest 6.0.26
  • @storybook/addon-knobs 6.0.26
  • @storybook/addon-links 6.0.26
  • @storybook/addon-storysource 6.0.26
  • @storybook/addon-viewport 6.0.26
  • @storybook/addons 6.0.26
  • @storybook/react 6.0.26
  • @storybook/theming 6.0.26
  • storybook-addon-performance 0.13.0

Other libraries

  • react 16.13.1
  • typescript 4.0.3
  • @babel/core 7.10.2
  • webpack 4.43.0

Affected platforms

Platform: Windows 10
Node version: 12.13.0
NPM version: 6.14.8

Screenshots / Screencast / Code Snippets (Optional)

Errors

ERROR in ./.storybook/storybook-init-framework-entry.js
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
ENOENT: no such file or directory, open 'C:\Users\stimmerm\git\saportal2\application\.storybook\storybook-init-framework-entry.js'
    at PoolWorker.fromErrorObj (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:262:12)
    at C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:204:29
    at mapSeries (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\node_modules\neo-async\async.js:3625:14)
    at PoolWorker.onWorkerMessage (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:170:35)
    at C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:152:14
    at Socket.onChunk (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\readBuffer.js:36:9)
    at Socket.emit (events.js:210:5)
    at Socket.Readable.read (_stream_readable.js:524:10)
    at Socket.read (net.js:608:39)
    at flow (_stream_readable.js:999:34)
    at emitReadable_ (_stream_readable.js:588:3)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/storybook-init-framework-entry.js ./node_modules/@storybook/addon-docs/dist/frameworks/common/config.js-generated-other-entry.js ./node_modules/@storybook/addon-docs/dist/frameworks/react/config.js-generated-other-entry.js ./node_modules/@storybook/addon-a11y/dist/a11yRunner.js-generated-other-entry.js ./node_modules/@storybook/addon-a11y/dist/a11yHighlight.js-generated-other-entry.js ./.storybook/preview.js-generated-config-entry.js ./.storybook/generated-stories-entry.js (webpack)-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined main[2]

ERROR in ./.storybook/preview.js-generated-config-entry.js
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 1)
ENOENT: no such file or directory, open 'C:\Users\stimmerm\git\saportal2\application\.storybook\preview.js-generated-config-entry.js'
    at PoolWorker.fromErrorObj (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:262:12)
    at C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:204:29
    at mapSeries (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\node_modules\neo-async\async.js:3625:14)
    at PoolWorker.onWorkerMessage (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:170:35)
    at C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:152:14
    at Socket.onChunk (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\readBuffer.js:36:9)
    at Socket.emit (events.js:210:5)
    at Socket.Readable.read (_stream_readable.js:524:10)
    at Socket.read (net.js:608:39)
    at flow (_stream_readable.js:999:34)
    at emitReadable_ (_stream_readable.js:588:3)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/storybook-init-framework-entry.js ./node_modules/@storybook/addon-docs/dist/frameworks/common/config.js-generated-other-entry.js ./node_modules/@storybook/addon-docs/dist/frameworks/react/config.js-generated-other-entry.js ./node_modules/@storybook/addon-a11y/dist/a11yRunner.js-generated-other-entry.js ./node_modules/@storybook/addon-a11y/dist/a11yHighlight.js-generated-other-entry.js ./.storybook/preview.js-generated-config-entry.js ./.storybook/generated-stories-entry.js (webpack)-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined main[7]

ERROR in ./.storybook/generated-stories-entry.js
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 2)
ENOENT: no such file or directory, open 'C:\Users\stimmerm\git\saportal2\application\.storybook\generated-stories-entry.js'
    at PoolWorker.fromErrorObj (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:262:12)
    at C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:204:29
    at mapSeries (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\node_modules\neo-async\async.js:3625:14)
    at PoolWorker.onWorkerMessage (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:170:35)
    at C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\WorkerPool.js:152:14
    at Socket.onChunk (C:\Users\stimmerm\git\saportal2\application\node_modules\thread-loader\dist\readBuffer.js:36:9)
    at Socket.emit (events.js:210:5)
    at Socket.Readable.read (_stream_readable.js:524:10)
    at Socket.read (net.js:608:39)
    at flow (_stream_readable.js:999:34)
    at emitReadable_ (_stream_readable.js:588:3)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)
 @ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/storybook-init-framework-entry.js ./node_modules/@storybook/addon-docs/dist/frameworks/common/config.js-generated-other-entry.js ./node_modules/@storybook/addon-docs/dist/frameworks/react/config.js-generated-other-entry.js ./node_modules/@storybook/addon-a11y/dist/a11yRunner.js-generated-other-entry.js ./node_modules/@storybook/addon-a11y/dist/a11yHighlight.js-generated-other-entry.js ./.storybook/preview.js-generated-config-entry.js ./.storybook/generated-stories-entry.js (webpack)-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined main[8]

./storybook/main.js

const path = require('path');

module.exports = {
    addons: [
        'storybook-addon-performance/register',
        '@storybook/addon-viewport/register',
        '@storybook/addon-actions/register',
        '@storybook/addon-a11y',
        '@storybook/addon-jest',
        '@storybook/addon-knobs/register',
        '@storybook/addon-backgrounds/register',
        '@storybook/addon-docs/preset',
        {
            name: '@storybook/addon-storysource',
            options: {
                rule: {
                    include: [
                        path.resolve(__dirname, '../resources'),
                        path.resolve(__dirname, '../stories'),
                    ],
                },
                loaderOptions: {
                    prettierConfig: {
                        trailingComma: 'all',
                        tabWidth: 4,
                        semi: true,
                        singleQuote: true,
                        printWidth: 100,
                        arrowParens: 'always',
                    },
                },
            },
        },
    ],
    // automatically import all files ending in *.stories.js/ts(x)/mdx in stories folder and resources folder
    stories: [
        '../resources/assets/es6_modules/**/*.stories.js',
        '../resources/assets/es6_modules/**/*.stories.jsx',
        '../resources/assets/es6_modules/**/*.stories.ts',
        '../resources/assets/es6_modules/**/*.stories.tsx',
        '../resources/assets/es6_modules/**/*.stories.mdx',
    ],
};

./storybook/manager.js

import { addons } from '@storybook/addons';
import { themes } from '@storybook/theming';

addons.setConfig({
    theme: themes.dark,
});

.storybook/preview.js

import { addParameters, addDecorator } from '@storybook/react';
import { withPerformance } from 'storybook-addon-performance';
import { withTests } from '@storybook/addon-jest';
import { themes } from '@storybook/theming';
import './scss/storybook.scss';
import '@storybook/addon-console';
import 'bootstrap/dist/css/bootstrap.css';
import 'font-awesome/css/font-awesome.css';
import '../resources/assets/es6_modules/app/app/scss/fonts/omnes/stylesheet.scss';
import '../resources/assets/es6_modules/app/app/scss/app/app.scss';
import '../resources/assets/es6_modules/app/app/scss/app/main-header.scss';
import '../resources/assets/es6_modules/app/app/scss/disable-responsive.scss';
import '../resources/assets/es6_modules/app/app/scss/notifications.scss';
import '../resources/assets/es6_modules/app/app/scss/notification-system.scss';

let results = null;

try {
    results = require('../.jest-test-results.json');
} catch (e) {
    console.warn(
        "'.jest-test-results.json': File not found. Test results will not be available in storybook.",
        "To fix this error, please run 'npm run test:generate-output' and re-run / rebuild storybook.",
    );
}

addDecorator(withPerformance);

addDecorator(withTests({ results: results ?? {}, filesExt: '.test.tsx' }));

// Possible background colors, with default 'white'
addParameters({
    backgrounds: [
        { name: 'white', value: '#FFFFFF', default: true },
        { name: 'dark', value: '#3F4448' },
        { name: 'twitter', value: '#00aced' },
        { name: 'facebook', value: '#3b5998' },
    ],
    options: {
        theme: themes.dark,
    },
});

.storybook/webpack.config.js

const path = require('path');
const projectWebpack = require('../webpack.config.src');
const fs = require('fs');
const sassGlobals = fs.readFileSync(path.resolve(__dirname, '../.js/globals.scss'));

// Export a function. Accept the base config as the only param.
module.exports = async ({ config }) => {
    // add css rules + add options for global scss
    config.module.rules.push({
        test: /\.scss$/,
        use: [
            'style-loader',
            'css-loader',
            {
                loader: 'sass-loader',
                options: {
                    data: sassGlobals,
                },
            },
        ],
        include: path.resolve(__dirname, '../'),
    });

    // Adding aliases
    config.resolve = { ...config.resolve, alias: projectWebpack.resolve.alias };

    // Add loader for typescript files
    config.module.rules.push({
        test: /\.jsx?$/,
        exclude: [/node_modules/, /j[qQ]uery/],
        use: [
            'thread-loader',
            {
                loader: 'babel-loader',
                options: {
                    cacheDirectory: path.resolve(__dirname, '../storage/es6/webpack/babel'),
                },
            },
        ],
    });

    config.module.rules.push({
        test: /\.tsx?$/,
        exclude: [/node_modules/, /j[qQ]uery/],
        use: [
            'thread-loader',
            {
                loader: 'babel-loader',
                options: {
                    cacheDirectory: path.resolve(__dirname, '../storage/es6/webpack/babel'),
                    plugins: [
                        [
                            'babel-plugin-react-docgen-typescript',
                            {
                                docgenCollectionName: 'STORYBOOK_REACT_CLASSES',
                                include: '\\.tsx$',
                                exclude: '(stories|tests|node_modules).*\\.(tsx|mdx)$',
                                shouldExtractLiteralValuesFromEnum: true,
                                skipPropsWithName: ['className', 'style'],
                                propFilter: (prop) => {
                                    // Exclude props that come from external dependencies. They can crowd up the
                                    // documentation table and likely already have their own docs available online.
                                    if (prop.parent) {
                                        return !prop.parent.fileName.includes('node_modules');
                                    }

                                    return true;
                                },
                            },
                        ],
                    ],
                    presets: [
                        '@babel/preset-env',
                        '@babel/preset-react',
                        '@babel/preset-typescript',
                    ],
                },
            },
        ],
    });

    // Enable typescript
    config.resolve.extensions.push('.ts', '.tsx');

    // Return the altered config
    return config;
};

Other notes

This is a JavaScript turned TypeScript project, so we are temporarily using babel to transpile TS, in order to prevent the build from failing on every type error. The project is quite large, so fixing them all is quite frankly an ongoing mammoth task.

@shilman
Copy link
Member

shilman commented Oct 22, 2020

Did you try removing node_modules and/or lockfiles and reinstalling?

If that doesn't work, try removing storybook-addon-performance? I notice it depends on 5.x stuff which could mess things up in 6.x.

@GeneLil
Copy link

GeneLil commented Nov 24, 2020

@Noldaru your webpack config uses the thread-loader, which is the issue for Storybook.

@fesor
Copy link

fesor commented Dec 7, 2020

Looks like the same issue as #9515, which was closed due to lack of activity. As mentioned in this issue, a problem with webpack-virtual-modules.

As a workaround you may try to apply thread-loader only to your application files and exclude .storybook for this loader.

@shilman
Copy link
Member

shilman commented Dec 10, 2020

Thanks for the workaround @fesor. Do you have a code snippet you can share?

@nigelellis
Copy link

nigelellis commented Apr 21, 2021

The workaround of excluding thread-loader under .storybook worked for me.

import {TsconfigPathsPlugin} from 'tsconfig-paths-webpack-plugin';

function webpackFinal(config, {configType}) => {
  const threadLoader = {
    loader: 'thread-loader',
    options: {
      poolTimeout: 500,
      workers: os.cpus().length,
      name: 'ts-pool',
    },
  };
  const tsLoader = {
    loader: 'ts-loader',
    options: {
      configFile: 'tsconfig.json',
      transpileOnly: true,
      happyPackMode: true,
      onlyCompileBundledFiles: true,
      experimentalFileCaching: true,
      compilerOptions: {
        module: 'esnext',
      },
    }
  };

  // Exclude .storybook from thread-loader
  config.module.rules = [
    {
      include: [/\.storybook/],
      exclude: [/node_modules/],
      test: /\.[jt]s(x?)$/,
      use: [
        tsLoader,
      ],
    },
    {
      exclude: [/node_modules/, /\.storybook/],
      test: /\.[jt]s(x?)$/,
      use: [
        threadLoader,
        tsLoader,
      ],
    },
  ]
  
  config.plugins = [
    ...(config.plugins ?? []),
    new webpack.ProvidePlugin({
      Buffer: ['buffer', 'Buffer'],
      process: 'process/browser',
    }),
  ];
  config.resolve.plugins = [
    new TsconfigPathsPlugin({
      configFile: path.resolve(__dirname, '../tsconfig.json'),
    }),
  ];
  config.resolve.symlinks = false;

  return config;
}

@LanFeusT23
Copy link

LanFeusT23 commented Sep 1, 2021

Running into the exact same issue, it works fine when running npm run storybook but npm run build-storybook throws the same errors.

Here's a repo that has the issue happening: https://github.com/LanFeusT23/vue3-storybook-test

  1. npm ci
  2. npm run build-storybook
    => throws same errors as this issue

@novay55555
Copy link

@LanFeusT23 You can try exclude .storybook in vue.config.js:

module.exports = {
  chainWebpack: config => {
    config.module.rule('js')
      .exclude
        .add(/\.storybook/)
        .end()
      .end()
  }
}

@Arios509
Copy link

Arios509 commented Apr 3, 2022

Hi guys, mine running default and upgrade from 6.0 to 6.4, still facing the same error. Didnt set the thread loader in webpack, but still no work.

@brunobg
Copy link

brunobg commented May 9, 2022

Workaround: use this on your vue.config.js:

  chainWebpack: (config) => {
    config.module.rule('js').uses.delete('thread-loader');
  }

@valentinpalkovic
Copy link
Contributor

This issue got stale. We did a lot of refactoring and optimizations in Storybook 7, and even the RC release of Storybook 8 is around the corner. Please try out the latest prerelease version of Storybook (npx storybook@next upgrade). I am closing this for now. Please let us know if the issue still exists in the latest version of Storybook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants