Level 102
Ensure that all files and folders in the project is owned by the user you use for the website/deployment etc.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I need always to use sudo when I want to run npm (sudo npm run prod).
Now I want to make a deploy script so it's not recommended to use sudo but if I type npm run prod it return me this error :
(node:589848) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, open '/data/www/my-site.com/public/mix-manifest.json'
at Object.openSync (fs.js:443:3)
at Object.writeFileSync (fs.js:1194:35)
at File.write (/data/www/my-site.com/node_modules/laravel-mix/src/File.js:157:12)
at Manifest.refresh (/data/www/my-site.com/node_modules/laravel-mix/src/Manifest.js:78:14)
at compiler.plugin (/data/www/my-site.com/node_modules/laravel-mix/src/webpackPlugins/ManifestPlugin.js:12:43)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/data/www/my-site.com/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:21:1)
at AsyncSeriesHook.lazyCompileHook (/data/www/my-site.com/node_modules/tapable/lib/Hook.js:154:20)
at Compiler.emitAssets (/data/www/my-site.com/node_modules/webpack/lib/Compiler.js:491:19)
at onCompiled (/data/www/my-site.com/node_modules/webpack/lib/Compiler.js:278:9)
at hooks.afterCompile.callAsync.err (/data/www/my-site.com/node_modules/webpack/lib/Compiler.js:681:15)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/data/www/my-site.com/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/data/www/my-site.com/node_modules/tapable/lib/Hook.js:154:20)
at compilation.seal.err (/data/www/my-site.com/node_modules/webpack/lib/Compiler.js:678:31)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/data/www/my-site.com/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/data/www/my-site.com/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeAssets.callAsync.err (/data/www/my-site.com/node_modules/webpack/lib/Compilation.js:1423:35)
at AsyncSeriesHook.eval [as callAsync] (eval at create (/data/www/my-site.com/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/data/www/my-site.com/node_modules/tapable/lib/Hook.js:154:20)
at hooks.optimizeChunkAssets.callAsync.err (/data/www/my-site.com/node_modules/webpack/lib/Compilation.js:1414:32)
at _promise1.then._result1 (eval at create (/data/www/my-site.com/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:589848) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Also when I npm run prod:
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /data/www/my-site.com/node_modules/@babel/compat-data
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/data/www/my-site.com/node_modules/@babel/compat-data'
npm ERR! { [Error: EACCES: permission denied, access '/data/www/my-site.com/node_modules/@babel/compat-data']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/data/www/my-site.com/node_modules/@babel/compat-data\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path:
npm ERR! '/data/www/my-site.com/node_modules/@babel/compat-data' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mabdellaoui/.npm/_logs/2021-10-28T11_28_44_327Z-debug.log
Should I change some permission in the server ?
Thanks
Please or to participate in this conversation.