nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.17k stars 2.31k forks source link

Error while executing nx run project-name:storybook #22042

Closed joaoantunes87 closed 6 months ago

joaoantunes87 commented 6 months ago

Current Behavior

I have just started a new nx workspace from scratch using react and vite. I have added some simple libraries with some ui components and everything works as expected.

Now I was trying to add storybook to one of those libraries following the documentation here.

After executing:

nx add @nx/storybook
nx g @nx/storybook:configuration ui --js --uiFramework=react-vite

Storybook configurations on project and nx.json seems to be well generated but when I executed:

nx run ui:storybook

I have the following error:

 NX   Unable to create nodes for libs/ui/.storybook/main.js using plugin @nx/storybook/plugin. 

         Inner Error: TypeError: Cannot read properties of undefined (reading 'parent')
    at traverse (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@phenomnomnominal/tsquery/dist/src/traverse.js:45:38)
    at traverseChildren (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@phenomnomnominal/tsquery/dist/src/traverse.js:30:5)
    at match (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@phenomnomnominal/tsquery/dist/src/match.js:12:37)
    at Function.query (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@phenomnomnominal/tsquery/dist/src/query.js:12:30)
    at getStorybookConfig (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@nx/storybook/src/plugins/plugin.js:169:60)
    at buildStorybookTargets (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@nx/storybook/src/plugins/plugin.js:68:32)
    at exports.createNodes (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@nx/storybook/src/plugins/plugin.js:52:15)
    at buildProjectsConfigurationsFromProjectPathsAndPlugins (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:148:29)
    at createProjectConfigurations (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:89:156)
    at _retrieveProjectConfigurations (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:61:12)

I am using version 18.0.5 of nx. Some of nx and storybook libraries on my package.json:

    "@nx/eslint": "18.0.5",
    "@nx/eslint-plugin": "18.0.5",
    "@nx/jest": "18.0.5",
    "@nx/js": "18.0.5",
    "@nx/react": "18.0.5",
    "@nx/rollup": "18.0.5",
    "@nx/storybook": "18.0.5",
    "@nx/vite": "18.0.5",
    "@nx/web": "18.0.5",
    "@nx/workspace": "18.0.5",
    "@rollup/plugin-url": "^7.0.0",
    "@storybook/addon-essentials": "7.6.17",
    "@storybook/addon-interactions": "^7.5.3",
    "@storybook/core-server": "7.6.17",
    "@storybook/jest": "^0.2.3",
    "@storybook/react-vite": "7.6.17",
    "@storybook/test-runner": "^0.13.0",
    "@storybook/testing-library": "^0.2.2",

I could not find anything about this error. It seems to be internal and while trying to execute storybook plugin. It seems that main.js is not even executed because I have tried some changes on it and the error was always the same.

Expected Behavior

Storybook to start for selected project.

GitHub Repo

No response

Steps to Reproduce

  1. Create a new nx workspace (integrated monorepo) with react-vite, e.g npx create-nx-workspace@latest react-monorepo --preset=react-monorepo;

options selected: imagem

  1. cd react-monorepo;
  2. Create ui library: nx g @nx/react:library ui --directory=libs/ui --js;

options selected:

imagem

  1. nx add @nx/storybook;
  2. nx g @nx/storybook:configuration ui --js --uiFramework=@storybook/react-vite;

options selected: imagem

  1. nx run ui:storybook;

Nx Report

Node   : 20.10.0
OS     : darwin-arm64
npm    : 10.2.3

nx                 : 18.0.5
@nx/js             : 18.0.5
@nx/linter         : 18.0.5
@nx/eslint         : 18.0.5
@nx/workspace      : 18.0.5
@nx/devkit         : 18.0.5
@nx/eslint-plugin  : 18.0.5
@nx/react          : 18.0.5
@nrwl/tao          : 18.0.5
@nx/vite           : 18.0.5
@nx/web            : 18.0.5
typescript         : 5.3.3

Failure Logs

NX   Unable to create nodes for libs/ui/.storybook/main.js using plugin @nx/storybook/plugin. 

         Inner Error: TypeError: Cannot read properties of undefined (reading 'parent')
    at traverse (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@phenomnomnominal/tsquery/dist/src/traverse.js:45:38)
    at traverseChildren (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@phenomnomnominal/tsquery/dist/src/traverse.js:30:5)
    at match (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@phenomnomnominal/tsquery/dist/src/match.js:12:37)
    at Function.query (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@phenomnomnominal/tsquery/dist/src/query.js:12:30)
    at getStorybookConfig (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@nx/storybook/src/plugins/plugin.js:169:60)
    at buildStorybookTargets (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@nx/storybook/src/plugins/plugin.js:68:32)
    at exports.createNodes (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/@nx/storybook/src/plugins/plugin.js:52:15)
    at buildProjectsConfigurationsFromProjectPathsAndPlugins (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:148:29)
    at createProjectConfigurations (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:89:156)
    at _retrieveProjectConfigurations (/Users/joaoantunes/Lab/product/monorepo/example-js/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:61:12)

Package Manager Version

No response

Operating System

Additional Information

No response

github-actions[bot] commented 5 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.