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

Error with adding script through cli #94

Closed
jonniebigodes opened this issue Feb 12, 2020 · 5 comments · Fixed by #105
Closed

Error with adding script through cli #94

jonniebigodes opened this issue Feb 12, 2020 · 5 comments · Fixed by #105
Assignees
Labels
bug Classification: Something isn't working

Comments

@jonniebigodes
Copy link
Contributor

While working on a pr on the learnstorybook repo i was following the steps of the tutorial up until the test section all is good up until the i'm executing the npx chromatic --app-code=<app-code> command. I let it run to completion, only when the process finishes and i'm presented with the following:

You have not added the 'chromatic' script to your 'package.json'. Would you like me to do it for you? y
chromatic info Added script 'chromatic'. You can now run it here or in CI with 'npm run chromatic' (or 'yarn chromatic')

NOTE: I wrote your app code to the 'CHROMATIC_APP_CODE' environment variable.

The app code cannot be used to read story data, it can only be used to create new builds.
If you would still prefer not to check it into source control, you can remove it from 'package.json' and set it via an environment variable instead.

As you can see i selected the yes (y) option to allow the cli to create a script to my project.
Now checking the package.json file i'm presented with the following:

{
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "storybook": "start-storybook -p 9009 -s public --ci",
    "build-storybook": "build-storybook -s public",
    "chromatic": "CHROMATIC_APP_CODE=my-app-code chromatic"
  },
 
  "devDependencies": {
    "@storybook/addon-actions": "^5.3.12",
    "@storybook/addon-links": "^5.3.12",
    "@storybook/addon-storyshots": "^5.3.13",
    "@storybook/addons": "^5.3.12",
    "@storybook/preset-create-react-app": "^1.5.2",
    "@storybook/react": "^5.3.12",
    "react-test-renderer": "^16.12.0",
    "storybook-chromatic": "^3.5.1"
  }
}

I'm just leaving in the necessary information, namely the devDependencies and the scripts available.

Now as me or any other user that goes with this route as soon as he/she makes any change and tries to run the script the following will be displayed:

'CHROMATIC_APP_CODE' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! taskbox-for-pr-278@0.1.0 chromatic: `CHROMATIC_APP_CODE=my-app-code chromatic`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the taskbox-for-pr-278@0.1.0 chromatic script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     \AppData\Roaming\npm-cache\_logs\2020-02-12T19_57_13_233Z-debug.log
The terminal process terminated with exit code: 1

This is not the first time this has popped up for me. while i was doing some work on another piece of documentation this issue presented itself, but i thought it might be a fluke, probably the package manager acting up or something on that nature.

Is this intended behaviour or something is amiss?

To add a bit more of context, i'm running on a windows 10 machine. Should anymore information be necessary i'm more than happy to push the code i'm using to a repo on GitHub.

Feel free to provide feedback

@jonniebigodes jonniebigodes changed the title Error with cli Error with adding script through cli Feb 12, 2020
@tmeasday
Copy link
Member

Thanks @jonniebigodes. I guess we need to use cross-env to set the environment variable so it works on windows.

@tmeasday tmeasday added the bug Classification: Something isn't working label Feb 13, 2020
@jonniebigodes
Copy link
Contributor Author

@ndelangen i see that a pr is up. Thank you very much for the time and effort you put into this issue.

@jonniebigodes
Copy link
Contributor Author

@ndelangen sorry to bother you, but it seems that this is still a issue. While working on the intro to storybook with ember, upon reaching the testing section the behaviour presented itself again. I thought that it could be a cached version. So i cleared the npm cache, recreated the project once again and added the dependency and it was still showing the same script.

Feel free to provide feedback

@ndelangen
Copy link
Member

We'll publish the new version with this fix next weekend @jonniebigodes, sorry for the delay.

@jonniebigodes
Copy link
Contributor Author

@ndelangen no problem, once again thank you for the time it was put into this. I'll be on the lookout and then when it's released i'll update things on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Classification: Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants