storybook 当项目路径中存在简单引号时出现错误,

azpvetkf  于 4个月前  发布在  其他
关注(0)|答案(4)|浏览(48)

描述bug

如果项目路径中包含一个简单的引号('),那么npm run storybook命令将无法正常工作。请注意,下面的日志中有test ' test目录:

ModuleParseError: Module parse failed: Unexpected token (8:116)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| /* eslint-disable import/no-unresolved */
> import { addDecorator, addParameters, addLoader, addArgTypesEnhancer } from 'C:/Users/Gagaro/PycharmProjects/test ' test/node_modules/@storybook/client-api';
| import { logger } from 'C:/Users/Gagaro/PycharmProjects/test ' test/node_modules/@storybook/client-logger';
| import * as config from 'C:/Users/Gagaro/PycharmProjects/test ' test/node_modules/@storybook/addon-actions/dist/esm/preset/addArgs.js';
    at handleParseError (C:\Users\Gagaro\PycharmProjects\test ' test\node_modules\@storybook\builder-webpack5\node_modules\webpack\lib\NormalModule.js:891:19)
    at C:\Users\Gagaro\PycharmProjects\test ' test\node_modules\@storybook\builder-webpack5\node_modules\webpack\lib\NormalModule.js:992:5
    at processResult (C:\Users\Gagaro\PycharmProjects\test ' test\node_modules\@storybook\builder-webpack5\node_modules\webpack\lib\NormalModule.js:718:11)
    at C:\Users\Gagaro\PycharmProjects\test ' test\node_modules\@storybook\builder-webpack5\node_modules\webpack\lib\NormalModule.js:778:5
    at C:\Users\Gagaro\PycharmProjects\test ' test\node_modules\@storybook\builder-webpack5\node_modules\loader-runner\lib\LoaderRunner.js:406:3
    at iterateNormalLoaders (C:\Users\Gagaro\PycharmProjects\test ' test\node_modules\@storybook\builder-webpack5\node_modules\loader-runner\lib\LoaderRunner.js:232:10)
    at C:\Users\Gagaro\PycharmProjects\test ' test\node_modules\@storybook\builder-webpack5\node_modules\loader-runner\lib\LoaderRunner.js:223:4
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
    at runNextTicks (internal/process/task_queues.js:62:3)
    at processImmediate (internal/timers.js:434:9)

重现方法

任何项目路径中包含简单引号的项目。
https://github.com/Gagaro/storybook-quote-bug

系统

Environment Info:

  System:
    OS: Windows 10 10.0.18363
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
  Binaries:
    Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 89.0.4389.128
    Edge: Spartan (44.18362.1474.0)
  npmPackages:
    @storybook/addon-actions: ^6.3.0-alpha.9 => 6.3.0-alpha.9
    @storybook/addon-essentials: ^6.3.0-alpha.9 => 6.3.0-alpha.9
    @storybook/addon-links: ^6.3.0-alpha.9 => 6.3.0-alpha.9
    @storybook/builder-webpack5: ^6.3.0-alpha.9 => 6.3.0-alpha.9
    @storybook/vue3: ^6.3.0-alpha.9 => 6.3.0-alpha.9
Environment Info:

  System:
    OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-7560U CPU @ 2.40GHz
  Binaries:
    Node: 14.16.0 - ~/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.11 - ~/bin/npm
  Browsers:
    Chrome: 88.0.4324.150
    Firefox: 87.0
  npmPackages:
    @storybook/addon-actions: ^6.3.0-alpha.9 => 6.3.0-alpha.9 
    @storybook/addon-essentials: ^6.3.0-alpha.9 => 6.3.0-alpha.9 
    @storybook/addon-links: ^6.3.0-alpha.9 => 6.3.0-alpha.9 
    @storybook/vue3: ^6.3.0-alpha.9 => 6.3.0-alpha.9
kiz8lqtg

kiz8lqtg1#

尝试以下代码:

import { addDecorator, addParameters, addLoader, addArgTypesEnhancer } from "C:/Users/Gagaro/PycharmProjects/test ' test/node_modules/@storybook/client-api";
ndasle7k

ndasle7k2#

它不在我的任何文件中。
请查看 https://github.com/Gagaro/storybook-quote-bug 以了解如何重现。

whitzsjs

whitzsjs3#

在Linux上重现:

Environment Info:

  System:
    OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-7560U CPU @ 2.40GHz
  Binaries:
    Node: 14.16.0 - ~/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.11 - ~/bin/npm
  Browsers:
    Chrome: 88.0.4324.150
    Firefox: 87.0
  npmPackages:
    @storybook/addon-actions: ^6.3.0-alpha.9 => 6.3.0-alpha.9 
    @storybook/addon-essentials: ^6.3.0-alpha.9 => 6.3.0-alpha.9 
    @storybook/addon-links: ^6.3.0-alpha.9 => 6.3.0-alpha.9 
    @storybook/vue3: ^6.3.0-alpha.9 => 6.3.0-alpha.9
xytpbqjk

xytpbqjk4#

@shilman can you reflag this as a bug please?

相关问题