patrikm96
patrikm96

Reputation: 108

Editing npm packages in a webapp

I have a web app in which I installed an npm package. Now I noted that I need to add code to customize it. I tried to go to node_modules, found the package, and edited it but the changes don't show. is there a way to do it? Also to avoid losing the changes I make to the packages I forked the package from GitHub.

----Update I have aa package called react-image-crop the relative path is node_modules/react-image-crop. Every time the below function gets called I want to log X and Y of the position:

  let pageX;
  let pageY;

  if (e.touches) {
    pageX = e.touches[0].pageX;
    pageY = e.touches[0].pageY;
  } else {
    pageX = e.pageX;
    pageY = e.pageY;
  }

  return {
    x: pageX,
    y: pageY,
  };
}

I tried to add console.log(pageX, pageY) but I don't get the respected output. the package I'm working on is https://github.com/DominicTobias/react-image-crop (hope I can have links to packages in my question otherwise I can delete it)

Upvotes: 0

Views: 62

Answers (1)

oklas
oklas

Reputation: 8220

If you need to modify npm package check this checklist:

  • check that you modify compiled/builded files (not a source)
  • check which exactly build you are modifying (packages may has multiple builds)
  • after you done and need some fix create issue in package tracker (or pr)
  • for constant fix for project (if long discussion or maintaining) use patch-package

Upvotes: 1

Related Questions