`The compilation process in webpack doesn't seem to be picking up changes in files being

When I run webpack --watch and make changes to my JS files, it doesn't automatically recompile.

I attempted to fix this by uninstalling webpack using npm uninstall, but the issue persists.

Does anyone have any suggestions on how to resolve this?

Answer №1

If you're experiencing issues with your code not recompiling, consider adjusting the watcher count on Ubuntu:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

For more information, visit:

Answer №2

Just a heads up: it appears that on OS X, there is a possibility for a folder to become corrupted and stop sending fsevents (which is used by watchpack, chokidar, and Finder) for itself and any subfolders. While I cannot confirm if this is the issue you are facing, it was certainly a frustrating experience for both myself and a colleague.

To resolve this issue, we simply renamed the corrupted parent folder, and immediately started receiving event updates as expected. For more detailed information, check out this blog post:

The solutions recommended in the aforementioned link include:

  • rebooting your computer
  • checking the disk and repairing permissions using Disk Utility
  • adding the folder to Spotlight's privacy list (list of folders not to be indexed), then removing it to trigger reindexing
  • renaming the folder, and potentially renaming it back
  • rebuilding the folder and moving the old contents into it

Our attempts at the first two methods were unsuccessful, we did not try the Spotlight approach, and ultimately recreating the folder was unnecessary for us.

We identified the problematic folder by systematically creating files in each parent directory within Finder until one began updating immediately (this bug affects Finder too). The top-level folder that remains unresponsive is likely the root cause. By simply moving it with mv and renaming it back, the monitoring functionality was restored.

The source of the corruption remains unknown, but we're relieved to have found a fix.

Answer №3

To resolve the problem I was facing, I found that including this snippet in my webpack setup did the trick. Remember to exclude the node_modules directory to prevent any performance issues with Hot Module Replacement (HMR):

watchOptions: {
  poll: true,
  ignored: /node_modules/
}

Answer №4

While using WebStorm, I encountered an issue that was causing problems.

After turning off Settings -> System Settings -> "safe write", the problem was resolved.

I found this solution on: WebPack Troubleshooting

Answer №5

The problem I encountered was related to folder case sensitivity. I realized that my code's require() calls used all lowercase path names, while the actual directories had uppercase letters in their names. By renaming all my directories to lowercase, webpack watching started working immediately.

Answer №6

In addition to the suggested solutions, I encountered a similar issue with my project directory being located within a Dropbox folder. Moving it outside of Dropbox resolved the issue for me. (running on OS X)

Answer №7

An important point to note is that using relative path names can lead to unexpected errors. For instance, I once mistakenly defined resolve.root as ./ instead of __dirname, which resulted in a significant amount of time being wasted on deleting and recreating files similar to what others have experienced.

Answer №8

If adjusting fs.inotify.max_user_watches like César mentioned doesn't resolve the issue, consider switching to polling instead of native watchers by following the instructions provided in the documentation or running webpack with the options --watch --watch-poll.

Answer №9

Keep in mind that running webpack in a virtual machine like Vagrant or Virtualbox may not trigger file updates in Ubuntu when changes are made on the host platform and stored in the shared folder. This can result in webpack not detecting the modifications.

For more information, refer to: Virtualbox ticket #10660

In my personal experience, making edits and saving files within the guest system (using vi) triggered webpack, while making changes on the host platform (using PhpStorm, Notepad, or other applications) did not prompt webpack to acknowledge them.

To resolve this issue, I utilized vagrant-fsnotify.

Answer №10

A simple solution to my issue was deleting the directory entirely and performing a fresh git clone from the repository.

Answer №11

Opportunities in Laravel Homestead

--live --poll-live

Answer №12

Encountered a similar problem while working on a .vue file. After restarting the server, everything functioned properly, but upon saving again, it failed to recompile. The root cause was identified as a single capitalized letter in the import file path. Detecting this issue proved challenging due to its intermittent nature, only appearing after a server reboot. Pay close attention to the case sensitivity of your file paths.

Answer №13

In order to avoid Vim renaming the original file and creating a new one, causing issues with webpack watch, consider setting backupcopy to yes instead of auto:

https://github.com/webpack/webpack/issues/781

If you are facing this problem, simply add the following line to your vim settings:

set backupcopy=yes

Answer №14

I encountered an issue with recompiling, only to realize later on that webpack actually monitors the dependency graph rather than just a specific folder or files. It turned out that the files I was modifying were not included in that graph.

Answer №15

I encountered a similar problem where neither webpack nor rollup in watch mode were detecting the modifications I made. Upon further investigation, I realized that the issue was due to my actions as I was modifying a module (.tsx file) that had not been imported anywhere in the application yet (such as App.ts which serves as the entry point). Consequently, I erroneously expected the build tools to highlight the errors I had introduced.

Answer №16

I encountered difficulties with creating folders and files in VS Code. To resolve this issue, I decided to re-clone my repository and opted to create new folders and files using the command line rather than within Code itself. It appeared that Code was somehow corrupting the files. Considering the recent update of the application, it is possible that a new bug has been introduced.

Answer №17

Encountered a similar issue while working within a VirtualBox (5.2.18) Ubuntu (18.04) VM using Vagrant (2.1.15) with rsync synchronization. Initially, the first build ran smoothly; however, subsequent changes were not being reflected in Webpack, despite setting

fs.inotify.max_user_watches=524288
. Even adding poll: true to the Webpack config did not resolve the issue.

Only the use of vagrant-notify-forwarder proved effective (unlike vagrant-fsnotify which failed for unknown reasons). However, the rebuild process occurred too quickly after saving a file on the host, suggesting that rsync may not have had sufficient time to complete its task (potentially due to the number of synced directories specified in my Vagrantfile).

To restore functionality to the watch feature, I opted to increase the value of aggregateTimeout in my Webpack configuration:

module.exports = {
  watch: true,
  watchOptions: {
    aggregateTimeout: 10000
  },
  ...
}

If this solution proves effective for you, consider gradually reducing the timeout value. Otherwise, be prepared for a 10-second delay each time you save a file before the build restarts. The default aggregateTimeout value is set at 300 ms.

Answer №18

To troubleshoot the problem, I discovered a capitalization discrepancy in an import path. The folder on the file system had a lowercase initial letter, while the import path utilized uppercase. Despite everything compiling without errors, it turned out to be a webpack watch include problem.

Answer №19

After encountering a similar problem myself, I discovered that the compilation error was due to the presence of special characters (*) in my project folder. By implementing the previous version of the watcher plugin, I was able to successfully resolve the issue. To integrate this solution into your webpack configuration file, simply add the following line:

plugins: [
    new webpack.OldWatchingPlugin()
  ]

Answer №20

Identifying the Root Cause:

It appears that the value assigned to max_user_watches in the file path

/proc/sys/fs/inotify/max_user_watches
is impacting webpack.

To verify your current value, run the command:

$cat /proc/sys/fs/inotify/max_user_watches
16384

In my situation, the value was set at 16384 and proved insufficient.

I experimented with various approaches including:

$ echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p

However, despite altering the value, it reverted back to the default setting of 16384 upon system restart.

Resolution for Linux OS (e.g., Manjaro in my case):

Begin by creating a new file:

sudo nano /etc/sysctl.d/90-override.conf

Add the following line:

fs.inotify.max_user_watches=200000

A value of 200000 proved effective for me.

After creating the file and updating the value, simply restart your computer to implement the changes successfully.

Answer №21

If you're using MacOS, a simple solution is as follows:

Begin by opening two terminal windows in the directory where your project is located.

In the first terminal window, execute: webpack --watch

In the second terminal window, run: webpack-dev-server

After testing numerous options, I've found this method to be the most dependable.

Answer №22

One potential resolution: adjusting the context to the application directory.

All of my webpack configuration files were located in a nested folder:

components/
webpack/
 development.js
app.js

In the file webpack/development.js, updating

context: path.join(__dirname, '../')
resolved the issue I was facing.

Answer №23

After experimenting with various approaches to resolve this issue, I eventually gave up. However, during the process of addressing a different problem, I decided to try again and surprisingly, the --watch flag started functioning properly.

Although I am unsure of the exact reason why it began working, the following steps seemed to have triggered its functionality:

1. Upgrading to the latest version of gcc
$ sudo port install gcc48
$ sudo port select --set gcc mp-gcc48

2. Updating to the newest clang version
$ sudo port install clang-3.6
$ sudo port select --set clang mp-clang-3.6

3. Setting the patch variables for C and C++ compilers
$ export CC=/opt/local/bin/clang
$ export CXX=/opt/local/bin/clang++

It is possible that while installing these packages, a dependency inadvertently resolved the missing element required for proper function.

Hopefully, this information will assist anyone facing challenges in getting it to work.

Answer №24

I found that removing the node_modules directory and then running npm install or yarn again to reinstall all of the packages resolved the issue for me.

Answer №25

If you're suddenly facing issues in your project, the following steps could help resolve the issue.

It's possible that the files responsible for tracking changes in your project, which webpack relies on, have become corrupted. You can recreate these files by following these simple steps:

  1. Navigate out of your project directory. ($: cd ..)
  2. Move your project to a different directory. ($: mv {projectName} {newName})
  3. Go into the new directory. ($: cd {newName})
  4. Start the server and verify if it reloads on every file change (this should work in most cases, as webpack will now create new files to monitor changes)
  5. Navigate out of the directory. ($: cd ..)
  6. Move the project back to its original name. ($: mv {newName} {projectNam})
  7. This approach worked for me successfully......

Answer №26

I wanted to share my favorite solution with everyone, so here is another answer. I use this method daily and it never fails me! Just make sure you have this library installed :

https://github.com/gajus/write-file-webpack-plugin

Description : This library ensures that webpack-dev-server writes bundle files to the file system.

Installation steps :

npm install write-file-webpack-plugin --save-dev

Answer №27

If you switch --monitor to -d --watch, it did the trick!

It fixed the issue for me.

Answer №28

While facing a similar issue, I stumbled upon this question which highlighted that webpack was not rebundling despite running webpack --config.

Curiously, even after deleting bundle.js, the webpage persisted in displaying the old version before my changes.

To solve this problem for anyone experiencing it, I resorted to selecting 'empty cache and hard reload' in Chrome (simply right-clicking the reload button with devtools open), and voila, the issue was resolved.

Answer №29

I encountered a similar problem and after trying numerous solutions, the one that worked for me was clearing browsing data in Chrome on my Mac.

These are the modules that have been installed:

"browser-sync": "^2.26.7",

"browser-sync-webpack-plugin": "^2.2.2",

"webpack": "^4.41.2",

"webpack-cli": "^3.3.9"

Answer №30

The issue stemmed from a confusion between .js and .ts files. Why is that?

During project build, Visual Studio would compile TypeScript files into .js and .js.map files unnecessarily. This duplication of compilation was redundant since webpack can handle TypeScript files using the awesome-typescript-loader plugin. While working on component .tsx files in Visual Studio Code or with the compileOnSave option disabled in tsconfig.json, changes made to the .ts file were not recompiled, causing webpack to process outdated .js files.

The solution involved preventing Visual Studio from compiling TypeScript files during project build by adding:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

to the PropertyGroup section of your .csproj file.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Interacting with a form input by triggering the onChange event

I am encountering a problem where I need to be able to select a radio button both onChange via keydown and mouse click. However, I am struggling with accessing both event parameters of the on keydown and on mouse click within the same function. As a result ...

Steps for choosing an option in MUI select list using jest

I am looking for a way to automate tests for a Material UI select component using Jest. Is there a way to select an option from the list of options in the Material UI component and confirm that its value has been successfully populated in Jest? I have se ...

Tips for retrieving a flag when there is a preexisting record within an association in Sequelize

I am working with a model A that has a 1:N association with a model B. My objective is to retrieve all records from A and determine whether there is at least one associated record from B (true) or not (false). The relationship setup: ModelA.hasMany(ModelB ...

Nested SetTimeout function fails to execute

Attempting to implement a button that provides feedback for its actions, I am faced with a challenge in Angular. After sending a put request to the server, the button's state changes to show this action. Upon receiving a response, the button's st ...

Retrieve information from various tables in a SQLite database using Node.js

Is there a method to retrieve all data from multiple tables in a database? Currently, I have managed to fetch all data from a single table: router.get('/', function (req, res, next) { db.serialize(function () { db.all('SELECT id, name ...

Retrieve the final ID of a dynamic div

Unable to find a solution, I am attempting to retrieve the ID of the most recently created div on the page. The code I have been using with .last() doesn't seem to be functioning correctly. My syntax may be incorrect, as I can't seem to extract a ...

Loop through the JSON data and dynamically display corresponding HTML code based on the data

I've developed a survey application using React, where I initially wrote code for each question to display radio buttons/inputs for answers. However, as the survey grew with multiple questions, this approach resulted in lengthy and repetitive code. To ...

I am retrieving data from a service and passing it to a component using Angular and receiving '[object Object]'

Searching for assistance with the problem below regarding my model class. I've attempted various approaches using the .pipe.map() and importing {map} from rxjs/operators, but still encountering the error message [object Object] export class AppProfile ...

Do you know the term for when JavaScript is utilized to display specific sections of a png image?

Imagine you have an image file in the format of a PNG which includes various icons intended for use on a website. How can JavaScript be utilized to choose and showcase a specific icon from that image? It's a technique I've observed in practice, b ...

Be mindful of potential missing dependencies when utilizing event listeners and states within useEffect

Whenever I utilize the addEventListener() method alongside trying to access some state within the useEffect, I consistently face the same issue. Adding the state as a dependency is not an option, as that would result in multiple event listeners being creat ...

No input value provided

I can't figure out what's going wrong. In other js files, this code works fine. Here is my HTML code: <table class='table'> <tr> <th>Event</th><td><input class='for ...

Combine two comma-separated strings in JavaScript to create an array of objects

I have two strings separated by commas that I want to transform into an array of objects. { "id": "1,2,3", "name": "test 1, test 2, test 3" } Is there a way to convert this into the desired object format? { &q ...

The Material-UI table spills out of its designated container

My material-ui table is resizing and scrolling horizontally without issue, but the table element and its contents are overflowing off the right side of the page. Check out this gif to see the behavior: https://i.stack.imgur.com/lXuHj.jpg Additionally, her ...

JS not functioning properly in specific pages causing display issues with page height set to 100%

I am facing an unusual issue where certain pages do not stretch to 100% page height in the middle section, causing the left-hand border to be incomplete. For example, on the 'Brentwood' site (please click on the 'Login' link in the top ...

"Is there a specific way to designate the content type as multipart form data when using Axios

I am experiencing difficulty with axios as I am unable to set the content type to multipart/form-data. Below is the code snippet: function (config) { // Do something before request is sent const isLogin = authService.isLogin(); if (isLogin) ...

Node.js (npm) is still unable to locate python despite setting %PYTHON% beforehand

Trying to get Node.js to work is proving to be more challenging than expected! Despite having two versions of Python on my computer, it seems that Node.js only works with the older version, 2.7. When I encountered an error, it prompted me to set the path ...

Explore an object to locate an element along with its parent

Here is an example of an object: $scope.categories = [ { value: 'One', id: 1, childs: [ { value: 'Two', id : 2, childs: [ { v ...

Body section CSS selector

Can a CSS selector be included within the body section of an HTML document? Here's an example of my code (although it is not functioning as expected): <html> <head> </head> <body> <div style= "a[target=_blank] {backgroun ...

What is the reason behind TypeScript choosing to define properties on the prototype rather than the object itself?

In TypeScript, I have a data object with a property defined like this: get name() { return this._hiddenName; } set name(value) { ...stuff... this._hiddenName = value; } However, when I look at the output code, I notice that the property is on ...

Error in whatsapp-web.js: Unable to access properties of an unidentified object (reading 'default')

As I followed the step-by-step guide on how to use whatsapp-web.js, I encountered an issue. Here is the link to the guide const { Client } = require('whatsapp-web.js'); const qrcode = require('qrcode-terminal'); const client = new Cl ...