我在WSL2 (Ubuntu20.04.1LTS)上运行npm run watch
。但是会得到以下错误。
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/DumpStack.log.tmp'
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/hiberfil.sys'
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/pagefile.sys'
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/swapfile.sys'
这是我的webpack配置
const path = require('path');
const devMode = process.env.NODE_ENV !== 'production';
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: {
"main": './views/js/main.js'
},
mode: 'development',
output: {
filename: 'js/[name].js',
chunkFilename: 'js/[id].[chunkhash].js',
path: path.resolve(__dirname, 'public')
},
module: {
rules: [
{
test: /\.js$/,
enforce: "pre",
use: ["source-map-loader"],
},
{
test: /\.css$/,
exclude: /node_modules/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{
loader: 'css-loader',
options: {
importLoaders: 1,
}
},
{ loader: 'postcss-loader' }
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: devMode ? 'css/[name].css' : 'css/[name].[hash].css'
})
],
devtool: 'cheap-module-source-map'
}
有没有人有同样的问题?你是怎么修复它的?
发布于 2021-07-09 14:07:18
ubuntu不喜欢你试图在/mnt/c中写入文件的事实,因为WSL并不总是正确地与ubuntu的权限系统绑定在一起,即使使用sudo,你也无法更改这些文件的权限。
我建议将目录更改为您知道用户拥有的位置(例如,您的文档库或usr/foldername),然后重试。
发布于 2021-04-20 23:31:22
问题出在文件的位置。它们应该在/home/user下,而不是/mnt/...
https://stackoverflow.com/questions/66841580
复制相似问题