最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Code in node_modules is not reflected in browser - Stack Overflow

programmeradmin7浏览0评论

I have forked the vuejs-datepicker project on Github (because of a bug in the project, but that is irrelevant in this matter). The changes I make to this forked project does not reflect in the end result in the browser, in my project that are using this dependency.

Here´s what I do:

  1. Add console.log´s, alerts and even remove som key functionality from the source code to make sure that the changes are easy to detect
  2. Commit and push the changes to the forked project
  3. In my main project I now run npm update, and afterwards I verify that the changes can be seen in the relevant file/files in the node_modules\vuejs-datepicker folder
  4. I run npm run serve and my main project loads. The changes I´ve made is not reflecting in the browser

File in node_modules folder:

The piled file in Chrome (I can verify that this is the running code with a breakpoint):

Package.json:

I´ve tried clearing the npm cache with npm cache clean, removing the project reference from package.json and reference it again, bumping the version, but it seems like it is using some cache from the first time I used this forked project which I can´t seem to locate. I´ve also tried clearing the dist folder and my browser´s cache which had no effect, but I guess webpack is making sure this is not an issue.

Am I missing anything here?

I have forked the vuejs-datepicker project on Github (because of a bug in the project, but that is irrelevant in this matter). The changes I make to this forked project does not reflect in the end result in the browser, in my project that are using this dependency.

Here´s what I do:

  1. Add console.log´s, alerts and even remove som key functionality from the source code to make sure that the changes are easy to detect
  2. Commit and push the changes to the forked project
  3. In my main project I now run npm update, and afterwards I verify that the changes can be seen in the relevant file/files in the node_modules\vuejs-datepicker folder
  4. I run npm run serve and my main project loads. The changes I´ve made is not reflecting in the browser

File in node_modules folder:

The piled file in Chrome (I can verify that this is the running code with a breakpoint):

Package.json:

I´ve tried clearing the npm cache with npm cache clean, removing the project reference from package.json and reference it again, bumping the version, but it seems like it is using some cache from the first time I used this forked project which I can´t seem to locate. I´ve also tried clearing the dist folder and my browser´s cache which had no effect, but I guess webpack is making sure this is not an issue.

Am I missing anything here?

Share Improve this question edited Oct 7, 2021 at 9:05 David Bradshaw 13.1k3 gold badges45 silver badges75 bronze badges asked Sep 28, 2020 at 20:09 FarsenFarsen 1,6973 gold badges26 silver badges53 bronze badges 5
  • 1 AFAIK npm update just updates packages. Have you piled the Vue files? – user4945014 Commented Sep 28, 2020 at 20:14
  • Isn´t the requried/referenced dependencies from node_modules piled, when i use npm build or npm run serve? – Farsen Commented Sep 29, 2020 at 5:07
  • Are you editing the files for the date picker within the node_modules folder? – user4945014 Commented Sep 29, 2020 at 14:29
  • No, as stated in step 1. and 2. I change the vuejs-datepicker code in the source, push it to git, and then download/npm update it in my main project. – Farsen Commented Sep 29, 2020 at 19:50
  • Since you're using Vue, you probably are using rollup or webpack with it. It may be configured to remove all console.logs from your code – Kasper Seweryn Commented Feb 22, 2021 at 2:40
Add a ment  | 

2 Answers 2

Reset to default 5 +50

Try the following mands to reset node_modules

rm -rf node_modules package-lock.json
npm install

In case someone ended up here. Check other caches as well. In my case I use next.js and I have to delete .next folder

发布评论

评论列表(0)

  1. 暂无评论