leostereo's avatar

mix: Permission denied

Hi guys. Im serving 2 projects using same laradock instance ProjectA is a fresh project ProjectB is an existing legacy project. I need to install some js packages using npm from workspace docker. On project A , I do: npm install algoliasearch. Then I write my code on bootstrap.js file and compile doing:

npm run dev

And everithing works properly.

Then on projectB , doing same , can not compile , it yelds:

}
npm WARN logfile Error: EACCES: permission denied, scandir '/root/.npm/_logs'
npm WARN logfile  error cleaning log files [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
npm WARN logfile   errno: -13,
npm WARN logfile   code: 'EACCES',
npm WARN logfile   syscall: 'scandir',
npm WARN logfile   path: '/root/.npm/_logs'
npm WARN logfile }
⸨⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠋ : WARN logfile Error: EACCES: permission denied, scandir '/root/.npm/_logs'
> development
> mix
sh: 1: mix: Permission denied

I have no idea how to fix this mix issue. I tryed: copy the projectB "scripts" section from package.js to projectB and chmod -R 777 to projectB folder.

BTW , neither projectA nor B can access to '/root/.npm/_logs. I think it would be usefull to fix this to get more info , but can not tweak my laracast workspace to write on log files.

0 likes
10 replies
Tray2's avatar

Never use 777 and never install npm as the root user. Your project should not have access to the root directory ever.

Are you using the root account on your machine?

If so

STOPP DOING THAT AT ONCE!!!

Create a normal use and use that.

sr57's avatar

@Tray2

1 - 1 :-)

su or sudo is a matter of preference when you are the administrator, personally I use sudo very rarely for me.

That said, it doesn't change anything to the final installation of node/npm.

Tray2's avatar

@sr57 su or sudo is a preference yes, but what I meant was that you should only use it when you need to and not all the time. Using root as a regular user is very bad in my book.

sr57's avatar

@leostereo

For a still unknown reason you try to run npm globally as a normal user.

What are the difference in your 2 package.json ?

Use also the cde "which npm" in each project to be sure it's the same.

leostereo's avatar

Hi guys , im following your discussion.

I would like to make clear that: Im running "npm run dev" command inside worspace container from laradock.

Inside workspace container , I can do "su laradock" , and then "npm run dev" but it returns "

sh: 1: mix: not found".

Whats your idea about running php artisan,npm u other commands as root or laradock user when running commands inside docker container?

Same ngnix mysq and workspace are serving both projects , and "which npm returns"

root@0930cca46693:/var/www/napsix# which npm
/home/laradock/.nvm/versions/node/v17.4.0/bin/npm

And these are my packaje.json files:

working fresh project, (projectA)

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "axios": "^0.21",
        "laravel-mix": "^6.0.6",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14"
    },
    "dependencies": {
        "@algolia/autocomplete-js": "^1.5.1",
        "@algolia/autocomplete-plugin-query-suggestions": "^1.5.2",
        "@algolia/autocomplete-theme-classic": "^1.5.2",
        "algoliasearch": "^4.12.1",
        "instantsearch.js": "^4.37.3"
    }
}

and non working legacy project (projectB):

{
	"private": true,
	"scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
	},
	"devDependencies": {
		"@pnotify/bootstrap4": "^5.2.0",
		"@pnotify/confirm": "^5.2.0",
		"@pnotify/core": "^5.2.0",
		"@pnotify/font-awesome5": "^5.2.0",
		"@pnotify/font-awesome5-fix": "^5.2.0",
		"axios": "^0.19",
		"bootstrap": "^4.0.0",
		"cross-env": "^7.0",
		"jquery": "^3.2",
		"laravel-mix": "^5.0.1",
		"lodash": "^4.17.13",
		"resolve-url-loader": "^3.1.0",
		"sass": "^1.15.2",
		"sass-loader": "^8.0.0",
		"vue-template-compiler": "^2.6.11"
	},
	"dependencies": {
		"@algolia/autocomplete-js": "^1.5.1",
		"@algolia/autocomplete-theme-classic": "^1.5.2",
		"ajv": "^6.12.2",
		"algoliasearch": "^4.12.1",
		"imagemin": "^6.0.0",
		"instantsearch.js": "^4.38.0",
		"popper.js": "^1.16.0",
		"preact": "^10.6.5",
		"vue": "^2.6.11"
	}
}

anyway .... thanks a lot for your feedback Leandro.

sr57's avatar

Have you run "npm install" first?

leostereo's avatar

Yes ... I did. BTW ... im think about build the project on a working platform and move the builded js files ... I know it sounds awfull , but mayit work ? Leandro.

sr57's avatar

@leostereo

For you information, I did a quick test on my server (debian) on 2 fresh laravel 8 projects, no pb with both config. It's probably due to your platform, let's know your last test ... and if it's not successful, give the exact config of your platform to find so who can do the test in the same condition.

Please or to participate in this conversation.