我正在尝试在刚刚安装和配置的 Linux Mint 上运行我的项目,但是当我运行 npm run dev 命令时。出现“spawn node_modules / webpack / bin / webpack.js EACCES”错误。
重装节点、升级版本、清除缓存节点、删除文件夹等网上提供的方法我都试过了。但仍然错误。
> @ dev /home/wirnat/Web/Bukasewa/bukasewa.vBETA
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
events.js:187
throw er; // Unhandled 'error' event
^
Error: spawn node_modules/webpack/bin/webpack.js EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: 'EACCES',
code: 'EACCES',
syscall: 'spawn node_modules/webpack/bin/webpack.js',
path: 'node_modules/webpack/bin/webpack.js',
spawnargs: [
'--progress',
'--hide-modules',
'--config=node_modules/laravel-mix/setup/webpack.config.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/wirnat/.npm/_logs/2019-10-17T12_37_01_854Z-debug.log
“也许这个问题与权限有关,但我只是在学习linux,并没有真正理解它。”
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
我只是按照上面的步骤操作并且成功了。
我今天遇到了同样的问题。这是我的解决方案
如果 node_modules 文件夹可以通过运行
ls -la (760 is recomended)
执行,请检查您的权限。如果一切正常,则尝试删除 node_modules 文件夹并通过运行 npm install
再次安装所有模块,然后根据您的部署环境运行命令 npm run development or production