I can't use npm run dev|prod|watch on my staging linux server. It produces this :
npm run production
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
}
> production
> mix --production
/var/www/html/preprodCerf2021/node_modules/laravel-mix/bin/cli.js:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47
nodeJs is up to date v 16.8.0 and npm v 7.21.0 my the compilation works perfectly on my windows dev machine.
This is the files ownership :
-rwxr-xr-x 1 www-data www-data 817 sept. 30 10:06 package.json
-rw-r--r-- 1 www-data www-data 820729 sept. 30 10:32 package-lock.json
-rwxr-xr-x 1 www-data www-data 1202 janv. 22 2021 phpunit.xml
drwxr-xr-x 8 www-data www-data 4096 sept. 8 16:02 public
-rwxr-xr-x 1 www-data www-data 3780 janv. 22 2021 README.md
drwxr-xr-x 8 www-data www-data 4096 août 31 12:55 resources
drwxr-xr-x 2 www-data www-data 4096 janv. 28 2021 routes
-rwxr-xr-x 1 www-data www-data 563 janv. 22 2021 server.php
drwxrwxr-x 6 www-data www-data 4096 mars 5 2021 storage
-rwxr-xr-x 1 www-data www-data 181 janv. 22 2021 .styleci.yml
-rwxr-xr-x 1 www-data www-data 548 sept. 9 15:36 tailwind.config.js
drwxr-xr-x 4 www-data www-data 4096 janv. 28 2021 tests
drwxr-xr-x 61 www-data www-data 4096 août 31 12:56 vendor
-rwxr-xr-x 1 www-data www-data 669 sept. 30 11:58 webpack.mix.js
CodePudding user response:
I've faced similar issues where I was trying to run npm as root user but the file ownership was with different users. You can try one of the following ways:
- Try running
npm
with the www-data user - Change ownership of the files to a sudoable user
# login as a user that has sudo access and change file ownership sudo chown -R myuser:myuser /path/to/project/ # run npm commands as myuser npm install && npm run production # change the permissions to previous state sudo chown -R www-data:www-data /path/to/project/
- Change ownership of the files to the root user (this hasn't worked for me so far but may work for you)
# enter sudo mode and change ownership to root sudo su chown -R root:root /path/to/project/ # run npm commands as root user npm install && npm run production # change the permissions to previous state chown -R www-data:www-data /path/to/project/ # exit sudo mode exit
CodePudding user response:
In the end I tried this succesfully, npm is very mysterious
rm node_modules -rf && npm install