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

Storiesof-to-csf codemod throws cannot find core-js module #8302

Closed
LeBenLeBen opened this issue Oct 5, 2019 · 2 comments
Closed

Storiesof-to-csf codemod throws cannot find core-js module #8302

LeBenLeBen opened this issue Oct 5, 2019 · 2 comments

Comments

@LeBenLeBen
Copy link
Contributor

LeBenLeBen commented Oct 5, 2019

Describe the bug
When running the codemod script to migrate storiesof stories to csf format, the command throws the following error:

Error: Cannot find module 'core-js/modules/es6.string.starts-with'

I've already tried everything suggested in #8267 but nothing worked so far.

To Reproduce
Steps to reproduce the behavior:

  1. Run npx -p @storybook/cli@next sb migrate storiesof-to-csf --glob "**/*.stories.js" in a project with some Storybook stories in the "storiesOf" format
  2. See error in the console

Expected behavior
The command should not throw

System:

npx -p @storybook/cli@next sb migrate storiesof-to-csf --glob "**/*.stories.js"
=> Applying storiesof-to-csf: 1 files
Processing 1 files...
Spawning 1 workers...
Sending 1 files to free worker...
internal/modules/cjs/loader.js:783
    throw err;
    ^

Error: Cannot find module 'core-js/modules/es6.string.starts-with'
Require stack:
- /Users/leben/.npm/_npx/11313/lib/node_modules/@storybook/cli/node_modules/@storybook/codemod/dist/transforms/storiesof-to-csf.js
- /Users/leben/.nvm/versions/node/v12.11.0/lib/node_modules/jscodeshift/src/Worker.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:780:15)
    at Function.Module._load (internal/modules/cjs/loader.js:685:27)
    at Module.require (internal/modules/cjs/loader.js:838:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/leben/.npm/_npx/11313/lib/node_modules/@storybook/cli/node_modules/@storybook/codemod/dist/transforms/storiesof-to-csf.js:5:1)
    at Module._compile (internal/modules/cjs/loader.js:945:30)
    at Module._compile (/Users/leben/.nvm/versions/node/v12.11.0/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:962:10)
    at Object.newLoader [as .js] (/Users/leben/.nvm/versions/node/v12.11.0/lib/node_modules/jscodeshift/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:798:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/leben/.npm/_npx/11313/lib/node_modules/@storybook/cli/node_modules/@storybook/codemod/dist/transforms/storiesof-to-csf.js',
    '/Users/leben/.nvm/versions/node/v12.11.0/lib/node_modules/jscodeshift/src/Worker.js'
  ]
}
All done.
Results:
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.951seconds

Additional context

Node v12.11.0
npm 6.11.3

Package.json:

{
  "name": "storybook-talk",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "start": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "storybook:build": "vue-cli-service storybook:build -c config/storybook",
    "storybook": "vue-cli-service storybook:serve -p 6006 -c config/storybook",
    "test:unit": "vue-cli-service test:unit"
  },
  "dependencies": {
    "core-js": "^2.6.5",
    "vue": "^2.6.10"
  },
  "devDependencies": {
    "@storybook/addon-actions": "^4.1.0 || ^5.0.0",
    "@storybook/addon-docs": "^5.3.0-alpha.10",
    "@storybook/addon-knobs": "^4.1.0 || ^5.0.0",
    "@storybook/addon-links": "^4.1.0 || ^5.0.0",
    "@storybook/addon-notes": "^4.1.0 || ^5.0.0",
    "@vue/cli-plugin-babel": "^3.11.0",
    "@vue/cli-plugin-eslint": "^3.11.0",
    "@vue/cli-plugin-unit-jest": "^3.11.0",
    "@vue/cli-service": "^3.11.0",
    "@vue/eslint-config-prettier": "^5.0.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^23.6.0",
    "eslint": "^5.16.0",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-vue": "^5.0.0",
    "prettier": "^1.18.2",
    "vue-cli-plugin-storybook": "^0.6.1",
    "vue-cli-plugin-tailwind": "^1.1.0",
    "vue-template-compiler": "^2.6.10"
  }
}

Component being converted:

import { storiesOf } from '@storybook/vue';
import { action } from '@storybook/addon-actions';

import Btn from '@/components/Btn.vue';

storiesOf('Button', module)
  .add('with text', () => ({
    components: { Btn },
    template: '<Btn @click="action">Hello Button</Btn>',
    methods: { action: action('clicked') },
  }))
  .add('with some emoji', () => ({
    components: { Btn },
    template: '<Btn @click="action">😀 😎 👍 💯</Btn>',
    methods: { action: action('clicked') },
  }));
@LeBenLeBen
Copy link
Contributor Author

Whoops, this is very similar to #8209, I'll let you decide if it's worth keeping separately or closed as duplicate.

@shilman
Copy link
Member

shilman commented Oct 6, 2019

Yeah closing as dupe to #8209. Thanks! 🙏

@shilman shilman closed this as completed Oct 6, 2019
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

2 participants