profile
viewpoint

Ask questionssb migrate doesn't work

Describe the bug I tried to migrate from storiesOf to CSF and the script couldn't run. I also had the same issue when running upgrade-hierarchy-separators.

To Reproduce Run npx -p @storybook/cli@next sb migrate storiesof-to-csf --glob="**/*.stories.tsx"

Errors:

npx -p @storybook/cli@next sb migrate --parser=tsx storiesof-to-csf --glob="**/*.stories.tsx"
=> Applying storiesof-to-csf: 57 files
npx: installed 217 in 8.391s
Processing 57 files... 
Spawning 11 workers...
Sending 6 files to free worker...
Sending 6 files to free worker...
Sending 6 files to free worker...
Sending 6 files to free worker...
Sending 6 files to free worker...
Sending 6 files to free worker...
Sending 6 files to free worker...
Sending 6 files to free worker...
Sending 6 files to free worker...
Sending 3 files to free worker...
/Users/henrycity/.npm/_npx/72712/lib/node_modules/@storybook/cli/node_modules/core-js/internals/global.js:13
check((typeof globalThis === "undefined" ? "undefined" : (0, _typeof2.default)(globalThis)) == 'object' && globalThis) || check((typeof window === "undefined" ? "undefined" : (0, _typeof2.default)(window)) == 'object' && window) || check((typeof self === "undefined" ? "undefined" : (0, _typeof2.default)(self)) == 'object' && self) || check((typeof global === "undefined" ? "undefined" : (0, _typeof2.default)(global)) == 'object' && global) || // eslint-disable-next-line no-new-func
                                                                              ^

TypeError: (0 , _typeof2.default) is not a function
    at Object.<anonymous> (/Users/henrycity/.npm/_npx/72712/lib/node_modules/@storybook/cli/node_modules/core-js/internals/global.js:8:9)
    at Module._compile (internal/modules/cjs/loader.js:1185:30)
    at Module._compile (/Users/henrycity/.npm/_npx/72734/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
    at Object.newLoader [as .js] (/Users/henrycity/.npm/_npx/72734/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:1034:32)
    at Function.Module._load (internal/modules/cjs/loader.js:923:14)
    at Module.require (internal/modules/cjs/loader.js:1074:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/henrycity/.npm/_npx/72712/lib/node_modules/@storybook/cli/node_modules/core-js/internals/path.js:1:14)
/Users/henrycity/.npm/_npx/72712/lib/node_modules/@storybook/cli/node_modules/core-js/internals/global.js:13
check((typeof globalThis === "undefined" ? "undefined" : (0, _typeof2.default)(globalThis)) == 'object' && globalThis) || check((typeof window === "undefined" ? "undefined" : (0, _typeof2.default)(window)) == 'object' && window) || check((typeof self === "undefined" ? "undefined" : (0, _typeof2.default)(self)) == 'object' && self) || check((typeof global === "undefined" ? "undefined" : (0, _typeof2.default)(global)) == 'object' && global) || // eslint-disable-next-line no-new-func

All done. 
Results: 
0 errors
0 unmodified
0 skipped
0 ok

Expected behavior All of the files are migrated to CSF.

Code snippets If applicable, add code samples to help explain your problem.

System: I cannot run npx sb@next info either.

I got this error

Environment Info:
(node:76369) UnhandledPromiseRejectionWarning: TypeError: (e || []).filter is not a function
    at /Users/henrycity/.npm/_npx/76369/lib/node_modules/sb/node_modules/envinfo/dist/envinfo.js:1:73314
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 6)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:76369) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:76369) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Though this is the system information I manually get

System:
    OS: macOS 10.15.6
  Binaries:
    Node: 14.0.0
    npm: 6.14.4
  npmPackages:
    "@storybook/addon-a11y": "6.0.5",
    "@storybook/addon-actions": "6.0.5",
    "@storybook/addon-docs": "^6.0.6",
    "@storybook/addon-jest": "6.0.5",
    "@storybook/addon-knobs": "6.0.5",
    "@storybook/addon-links": "6.0.5",
    "@storybook/addon-viewport": "6.0.5",
    "@storybook/preset-create-react-app": "^3.1.4",
    "@storybook/react": "6.0.5",
    "@storybook/theming": "6.0.5",
    "core-js": "^3.6.5",
storybookjs/storybook

Answer questions alexandernanberg

I'm getting a similar error

TypeError: $ is not a function
    at Object.<anonymous> (/Users/alna/.npm/_npx/42307/lib/node_modules/@storybook/cli/node_modules/core-js/modules/es.regexp.exec.js:5:1)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Module._compile (/Users/alna/.npm/_npx/42314/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Object.newLoader [as .js] (/Users/alna/.npm/_npx/42314/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/alna/.npm/_npx/42307/lib/node_modules/@storybook/cli/node_modules/core-js/internals/fix-regexp-well-known-symbol-logic.js:3:1)
❯ npx sb@next info  

Environment Info:

  System:
    OS: macOS 10.15.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.7 - ~/dev/decibel/node_modules/.bin/npm
  Browsers:
    Chrome: 84.0.4147.125
    Firefox: 79.0
    Safari: 13.1.2
  npmPackages:
    @storybook/addon-actions: 6.0.10 => 6.0.10 
    @storybook/addon-backgrounds: 6.0.10 => 6.0.10 
    @storybook/addon-docs: 6.0.10 => 6.0.10 
    @storybook/addon-knobs: 6.0.10 => 6.0.10 
    @storybook/addon-storysource: 6.0.10 => 6.0.10 
    @storybook/addons: 6.0.10 => 6.0.10 
    @storybook/react: 6.0.10 => 6.0.10 
    @storybook/theming: 6.0.10 => 6.0.10 
useful!
source:https://uonfu.com/
Github User Rank List