0

I am using react-cropper for my project, it includes cropper version ^0.10.0 while I need some methods of cropper version 0.11.1. So I forked this to my own GitHub repository and wanted to upgrade its cropper to 0.11.1. But I don't know how to do!

Do I have to build this module again and push to GitHub, then install it via GitHub url in package.json?

thanks!


updated

I cloned react-cropper to local, update package.json and then npm install. It threw error Error: ENOENT, no such file or directory 'dist/react-cropper.js'. Then I mkdir dist and npm install successfully. how to do next?


Updated 2 After following @Michelem answer, I upgraded successfully cropper to 0.11.1 But then when I run gulp it threw error: can not find module 'react-cropper' is this related to this issue or not?

Kapuzzi
  • 98
  • 8
  • yes. Update your package.json with latest module version. do npm install. – Abie Sep 08 '15 at 06:14
  • I cloned react-cropper to local, update `package.json` and then `npm install`. It threw error `Error: ENOENT, no such file or directory 'dist/react-cropper.js'`. Then I `mkdir dist` and `npm install ` successfully. how to do next? – Kapuzzi Sep 08 '15 at 06:23

3 Answers3

0

You don't need any fork, just change the package.json version with something like this: ~0.11 (this will get always the latest 0.11.x version).

Then run npm install.

Otherwise you can also leave the package.json as is and run npm update cropper but then you need to check how the package was defined, if it was ^0.10.0 it should be updated to 0.11.1.

You can also check this to understand what the ^ and ~ means.

EDIT:

If you need to change a dependency version from a package you don't own you have to follow this steps:

  1. Fork the Github repository (react-cropper)
  2. Change the package.json inside the repo to match your needed version, so for example change to this:

    "dependencies": {
       "cropper": "~0.11.0"
    },
    
  3. Save the file and push it to your forked repo
  4. Get the commit url like this: https://github.com/roadmanfong/react-cropper/commit/b3be6918af66b23cbc100d193cb0df853fd67586
  5. Change commit with tarballso you get an URL like this: https://github.com/roadmanfong/react-cropper/tarball/b3be6918af66b23cbc100d193cb0df853fd67586
  6. Put all togheter in your app package.json:

    "react-cropper": "https://github.com/roadmanfong/react-cropper/tarball/b3be6918af66b23cbc100d193cb0df853fd67586",
    
  7. Run npm install

This will update your react-cropper package inside your app getting it from your Github repo so it will have cropper 0.11.1 as dependency.

Community
  • 1
  • 1
michelem
  • 14,430
  • 5
  • 50
  • 66
  • I think you have misunderstood, here is the flow, my app's `package.json` depends on `react-cropper`, then `react-cropper` depends on `cropper`. So I have to update version of `cropper` in `react-cropper 's package.json`? – Kapuzzi Sep 08 '15 at 06:30
  • thanks for your answer, I tried and updated successfully `cropper` to `0.11.1` but then, when I run `gulp` It throw error `can not find module 'react-cropper'`. Is this error related to upgrading? Or I will post another question about require('react-cropper')? thanks! – Kapuzzi Sep 08 '15 at 06:47
  • You shouldn't install cropper "standalone" while react-cropper needs it as dependency. It's not the same. You need to follow the steps I wrote. – michelem Sep 08 '15 at 06:48
  • Ah, I meant I followed your steps! – Kapuzzi Sep 08 '15 at 06:50
  • In your package.json APP file you should have only the definition of "react-cropper" with your forked version. Then run `npm innstall react-cropper` I cannot understand because you are installing cropper as app module if it's only a dependency of react-croppper – michelem Sep 08 '15 at 06:53
  • yes, I did as you said, only have this `"react-cropper": "https://github.com/dang-hoang-hieu/react-cropper/tarball/f6d0d6859a8f6e188a2c29989ebaa60f13bc6e82",` I don't install cropper as dependency in my app. I think the problem is I have to build it again. Because when I look at `react-cropper` module in `node_modules` directory, compare between before and after. I notice that the after upgrading version doesn't have file `dist/react-cropper.js` :( – Kapuzzi Sep 08 '15 at 07:01
0

npm update cropper --save

Save version for you in package.json

11111000000
  • 193
  • 2
  • 9
  • I have a comment [here](http://stackoverflow.com/questions/32450414/how-to-upgrade-nodejss-module-dependency-to-newer-version#comment52764003_32450622) – Kapuzzi Sep 08 '15 at 06:32
  • Then you're need to make fork and fix package.json link to this fork – 11111000000 Sep 08 '15 at 06:34
0

To update outdated cropper package + change the package.json accordingly,use

npm install cropper@0.11.1 --save.
napster
  • 349
  • 1
  • 4
  • 16