Аfter compilation webpack, it gives an error Watchpack Error (initial scan): Error: EACCES: permission denied
Describe the bug
After compilation, errors occur as shown in the screenshot below. Further devServer does not work.
What is the current behavior?

- Operating System: Windows 10 pro
- Node Version: v14.15.0
- NPM Version: 6.14.8
- webpack Version: ^5.3.2
- webpack-dev-server Version: ^3.11.0
- Browser: Chrome
- [x] This is a bug
- [ ] This is a modification request
Code
// webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
context: path.resolve(__dirname, 'src'),
mode: 'development',
//devtool: false,
entry: {
main: './index.js',
analytics: './analytics.js'
},
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: ['.js', '.json', '.png'],
alias: {
'@models': path.resolve(__dirname, 'src/models'),
'@': path.resolve(__dirname, 'src'),
}
},
optimization: {
splitChunks: {
chunks: 'all'
}
},
devServer: {
publicPath : '/'
},
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader','css-loader' ],
},
{
test: /\.(png|jpg|svg|gif)$/,
use: [ 'file-loader' ],
},
{
test: /\.(ttf|woff|woff2|eot)$/,
use: [ 'file-loader' ],
},
{
test: /\.xml$/,
use: [ 'xml-loader' ],
},
{
test: /\.csv$/,
use: [ 'csv-loader' ],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './index.html',
title: 'webpack5'
}),
new CleanWebpackPlugin({
verbose: true,
cleanOnceBeforeBuildPatterns: [path.resolve(__dirname, 'dist')],
}),
]
}
// package.json
{
"name": "webpack5",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"start": "webpack serve --mode development"
},
"author": "alex",
"license": "ISC",
"devDependencies": {
"clean-webpack-plugin": "^3.0.0",
"css-loader": "^5.0.0",
"csv-loader": "^3.0.3",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.0.0-alpha.7",
"papaparse": "^5.3.0",
"path": "^0.12.7",
"sass-loader": "^10.0.4",
"style-loader": "^2.0.0",
"webpack": "^5.3.2",
"webpack-cli": "^4.1.0",
"webpack-dev-server": "^3.11.0",
"xml-loader": "^1.2.1"
},
"dependencies": {
"jquery": "^3.5.1",
"normalize.css": "^8.0.1"
}
}
Expected Behavior
Actual Behavior
For Bugs; How can we reproduce the behavior?
Steps to reproduce the behavior:
Define a devServer config in your webpack config file Run npm run start Expected behavior
For Features; What is the motivation and/or use-case for the feature?
I use wsl2, when using powershell there is no such problem
Can't reproduce, these problem from watchpack and I don't know why you watch /tmp
Can't reproduce
I can, with WSL1, happy to help.
these problem from
watchpack
Maybe? Certainly the error is printed by watchpack, but if it's being told to watch an unreasonable file (like Windows' swapfile), then that might be a bug in a caller of watchpack rather than watchpack itself.
and I don't know why you watch /tmp
Note that it's not /tmp, it's /mnt/c aka C:\. My config certainly doesn't tell it to. In fact, none of my package.json or other configs even mention watchpack or webpack-dev-server, yet they're installed and used (and have been working fine). I can imagine this being a watchpack bug where, if you tell it to watch C:\...\somefile, it walks up the tree and tries to lstat every directory along the way, which fails for C:\ because it contains some files that the user doesn't have access to.
I can add that this error message wasn't there with webpack v4.
Any luck with this issue? I'm getting the same response with webpack 5.21.2 and webpack-dev-server 3.11.2. It's kinda hard to find good info to solve it.
I am getting the same answer, how to solve this problem? I am using webpack: 5.17.0, the old version did not have. Thanks
Same here with WSL 2.0
Same here with WSL 2.0
I just ported my entire project to outside /mnt/c/ i.e. /mnt/z. This solved the issue in WSL2.
same issue with
- wsl debian 1
- vagrant
- laravel-mix 6
- webpack 5
is there a better solution that moving all my repos like @yashgupta-7 says.
Try https://webpack.js.org/configuration/watch/#watchoptionspoll
Fails with the same errors on
- WSL Ubuntu 18.04.4
- NextJs
- Webpack 5
Noticed this while testing out NextJs. NextJs made webpack 5 the default version in their app bootstrap. But at least they've done some diligence by providing the ability to disable the use of this version in the config. Disabling it makes the app run with webpack 4 instead. While using webpack 4, the app runs as expected.
I use wsl2, when using powershell there is no such problem
Not sure why this has so many down votes. I also tried using PowerShell and the CMD line through the Windows Terminal and live reload works without error in both cases.
I can paste my webpack files if needed.
Here the original error https://github.com/webpack/watchpack/issues/187
I have found a way to run the npm run watch by navigating to ~ running git clone then npm install and npm run watch but I can't access those files with VS Code to update them. At work, I develop folders that exist in c\user\dboyea just like I am trying now. I don't know the difference.