[Bug]: Storybook无法解析yarn Plug N Play(Babel?)依赖项

fhity93d  于 2个月前  发布在  Yarn
关注(0)|答案(4)|浏览(40)

描述bug

当我运行 build-storybook 时,我看到了与这里报告的相同的错误输出行为:#18801 (评论)
build-storybook 无限挂起,无法终止或完成。
我只在使用 yarns 'plug n' play'模式或'zero-installs'时看到这些错误。如果我将 yarn nodeLinker 值更改为 nodeLinker: node-modules ,那么 build-storybook 可以成功运行。
我尝试遵循 #18801 (评论)的建议并尝试升级到 npx sb@next upgrade --prerelease
然而,升级过程在babel迁移步骤中失败,报错:

✅ ran autodocsTrue migration
⚠️  failed to check fix missing-babelrc
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@babel/plugin-proposal-class-properties' imported from /Users/kevzettler/code/react-regl/babel-virtual-resolve-base.js
    at new NodeError (/Users/kevzettler/.npm/_npx/eebb2d3a7d26a7f1/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:2240:5)
    at packageResolve (/Users/kevzettler/.npm/_npx/eebb2d3a7d26a7f1/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:2776:9)
    at moduleResolve (/Users/kevzettler/.npm/_npx/eebb2d3a7d26a7f1/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:2804:18)
    at defaultResolve (/Users/kevzettler/.npm/_npx/eebb2d3a7d26a7f1/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:2835:13)
    at /Users/kevzettler/.npm/_npx/eebb2d3a7d26a7f1/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:2855:14
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/kevzettler/.npm/_npx/eebb2d3a7d26a7f1/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:45:103)
    at _next (/Users/kevzettler/.npm/_npx/eebb2d3a7d26a7f1/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:46:194)
    at /Users/kevzettler/.npm/_npx/eebb2d3a7d26a7f1/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:46:364
    at new Promise (<anonymous>) {
  code: 'ERR_MODULE_NOT_FOUND'
}

此外,如果我回退并在使用 yarns nodeLinker :node-modules 模式下执行 npx sb@next upgrade --prerelease ,它会成功通过。
这使我相信在我的情况下可能存在模块解析问题,可能是由于.babelrc文件正在处理storybook。

重现问题

我在此处创建了一个重现仓库:
https://github.com/kevzettler/storybook-bug-example
这种情况发生在以下依赖项上
Node版本 v16.13.0
yarn -v
3.3.1
您可以执行以下shell命令序列来设置仓库并触发失败情况

git clone https://github.com/kevzettler/storybook-bug-example.git && cd storybook-bug-example && yarn install && yarn build-storybook

然后,您可以执行 npx sb@next upgrade --prerelease 以查看升级失败情况。
相反地,您可以编辑 .yarnrc.yml 以启用 nodeLinker: node-modules 并查看成功情况。

系统环境

Environment Info:

  System:
    OS: macOS 12.4
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 3.3.1 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
    Safari: 15.5

其他上下文

  • 无响应*
u0njafvf

u0njafvf1#

@yannbf 这是否是yarn pnp中babel迁移的问题?

zhte4eai

zhte4eai2#

这可能是一个问题:
info @storybook/addon-options ^5.3.21 → ^6.0.0-alpha.29

mkh04yzy

mkh04yzy3#

我不知道这是否是你能够访问的内容,@kevzettler:
https://ndelangen-glorious-guide-4gpxjv4vp5394j.github.dev/
但是我成功生成了PNP文件,尽管由于缺少预构建的软件包而无法安装。日志如下:

# This file contains the result of Yarn building a package (gl@npm:4.9.2)
# Script name: install

prebuild-install WARN install No prebuilt binaries found (target=19.5.0 runtime=node arch=x64 libc= platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.2
gyp info using node@19.5.0 | linux | x64
gyp info find Python using Python version 3.10.4 found at "/home/codespace/.python/current/bin/python3"
gyp ERR! UNCAUGHT EXCEPTION 
gyp ERR! stack TypeError: Cannot assign to read only property 'cflags' of object '#<Object>'
gyp ERR! stack     at createConfigFile (/workspaces/storybook-bug-example/.yarn/unplugged/node-gyp-npm-7.1.2-002c5798eb/node_modules/node-gyp/lib/configure.js:117:21)
gyp ERR! stack     at /workspaces/storybook-bug-example/.yarn/unplugged/node-gyp-npm-7.1.2-002c5798eb/node_modules/node-gyp/lib/configure.js:84:9
gyp ERR! stack     at /workspaces/storybook-bug-example/.pnp.cjs:17916:13
gyp ERR! System Linux 5.4.0-1100-azure
gyp ERR! command "/usr/local/share/nvm/versions/node/v19.5.0/bin/node" "/workspaces/storybook-bug-example/.yarn/unplugged/node-gyp-npm-7.1.2-002c5798eb/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /workspaces/storybook-bug-example/.yarn/unplugged/gl-npm-4.9.2-431907383a/node_modules/gl
gyp ERR! node -v v19.5.0
gyp ERR! node-gyp -v v7.1.2
gyp ERR! Node-gyp failed to build your package.
gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.
wz3gfoph

wz3gfoph4#

这可能是个问题:

# This file contains the result of Yarn building a package (gl@npm:4.9.2)

@storybook/addon-options ^5.3.21 → ^6.0.0-alpha.29
我尝试用 yarn remove @storybook/addon-options 删除这个,但问题仍然存在。
我不知道你是否能解决这个问题 @kevzettler:
https://ndelangen-glorious-guide-4gpxjv4vp5394j.github.dev/
我无法访问这个
那个 gl build error...

# This file contains the result of Yarn building a package (gl@npm:4.9.2)

可能与
regl-project/regl#655

相关问题