Executing Karma giving permission denied error - node.js

I installed karma locally using
npm install karma --save-dev
and then i tried
$ ./node_modules/karma/bin/karma start
Then i get this error
vagrant#development:$ ./node_modules/karma/bin/karma start
-bash: ./node_modules/karma/bin/karma: Permission denied
vagrant#development:$ ls -liah ./node_modules/karma/bin/
total 4.0K
54696 drwxrwxr-x 1 vagrant www-data 102 Nov 17 19:24 .
54688 drwxrwxr-x 1 vagrant www-data 544 Nov 17 15:57 ..
54697 -rw-rw-r-- 1 vagrant www-data 50 Nov 15 02:43 karma
What can be the reason
http://karma-runner.github.io/0.12/intro/installation.html
vagrant#development:$ sudo chmod +x ./node_modules/karma/bin/karma
vagrant#development:$ ls -liah ./node_modules/karma/bin/
total 4.0K
54696 drwxrwxr-x 1 vagrant www-data 102 Nov 17 19:24 .
54688 drwxrwxr-x 1 vagrant www-data 544 Nov 17 15:57 ..
54697 -rw-rw-r-- 1 vagrant www-data 50 Nov 15 02:43 karma

Your ./node_modules/karma/bin/karma executable does not have execution privileges for your user. You can chmod it to give you the right privileges with:
$ chmod +x ./node_modules/karma/bin/karma
To avoid this in the future, simply install it with npm install -g karma-cli (globally).

Related

Laravel mix npm run dev on linux produce SyntaxError: missing ) after argument list

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
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
In the end I tried this succesfully, npm is very mysterious
rm node_modules -rf && npm install

Tomcat installed folder access is denied on linux

Please find below set of cmds & outputs
[ec2-user#ip-172-31-38-218 opt]$ ls -al
total 9416
drwxr-xr-x 3 root root 4096 Nov 7 13:52 .
dr-xr-xr-x 25 root root 4096 Nov 7 13:16 ..
-rw-r--r-- 1 root root 9625824 Sep 4 22:52 apache-tomcat-8.5.34.tar.gz
drwxr-xr-x 5 root root 4096 Aug 11 01:26 aws
[ec2-user#ip-172-31-38-218 opt]$ sudo groupadd tomcatgrp
[ec2-user#ip-172-31-38-218 opt]$ sudo useradd -s /bin/false -g tomcatgrp -d /opt/tomcatfolder tomcatuser
[ec2-user#ip-172-31-38-218 opt]$ ls -al
total 9420
drwxr-xr-x 4 root root 4096 Nov 7 13:53 .
dr-xr-xr-x 25 root root 4096 Nov 7 13:16 ..
-rw-r--r-- 1 root root 9625824 Sep 4 22:52 apache-tomcat-8.5.34.tar.gz
drwxr-xr-x 5 root root 4096 Aug 11 01:26 aws
drwx------ 2 tomcatuser tomcatgrp 4096 Nov 7 13:53 tomcatfolder
Now, when I run the cmd I am getting Permission denied as follows
[ec2-user#ip-172-31-38-218 opt]$ cd /opt/tomcatfolder/
-bash: cd: /opt/tomcatfolder/: Permission denied
Can you please help in resolving this above issue..?
I followed instructions of installing Tomcat from this link how-to-install-apache-tomcat-8-on-centos-7
It seems you are the ec2-user, but the directory is owned by tomcatuser and the permissions on the directory do now allow other users or groups to read it.
Try sudo chmod 755 /opt/tomcatfolder/ and then cd into it.
That will add read and execute permissions to the directory.

Laravel Messed up Homestead Permissions

I seem to have messed up Homestead's Linux Permissions, my app is throwing exceptions like not being able to find views that are there and "Impossible to create Root Directory".
I did do a recursive chmod a little while ago which i think is the cause of the problem, the issue is i don't quite know how to revert that.
In my after.sh Homestead script i'm setting the following Provisioning rules
sudo chown -R www-data:www-data /home/vagrant/Code/myapp
sudo usermod -a -G www-data vagrant
sudo find /home/vagrant/Code/myapp -type f -exec chmod 644 {} \;
sudo find /home/vagrant/Code/myapp -type d -exec chmod 755 {} \;
sudo chgrp -R www-data /home/vagrant/Code/myapp/storage /home/vagrant/Code/myapp/bootstrap/cache
sudo chmod -R ug+rwx /home/vagrant/Code/myapp/storage /home/vagrant/Code/myapp/bootstrap/cache
I execute those and nothing happens, it's still getting the same errors, so i went and checked NGINXs nginx.conf file and it's referencing vagrant as it's user so that's correct...
And calling ls -lsa on my root project folder (inside of the Vagrant VM) returns the following information. Any help would be much appreciated, thank you.
0 drwxr-xr-x 1 vagrant vagrant 1280 Dec 18 13:59 .
4 drwxr-xr-x 3 root root 4096 Dec 18 13:29 ..
4 -rw-r--r-- 1 vagrant vagrant 1771 Dec 18 13:59 after.sh
8 -rw-r--r-- 1 vagrant vagrant 7314 Nov 21 09:24 aliases
0 drwxr-xr-x 1 vagrant vagrant 320 Dec 17 17:39 app
4 -rw-r--r-- 1 vagrant vagrant 1646 Nov 21 09:24 artisan
0 drwxr-xr-x 1 vagrant vagrant 160 Dec 12 17:01 bootstrap
4 -rw-r--r-- 1 vagrant vagrant 1707 Dec 17 17:51 composer.json
172 -rw-r--r-- 1 vagrant vagrant 175864 Dec 18 13:24 composer.lock
0 drwxr-xr-x 1 vagrant vagrant 544 Dec 18 13:50 config
4 -rw-r--r-- 1 vagrant vagrant 1534 Nov 21 09:24 CONTRIBUTING.md
8 -rw-r--r-- 1 vagrant vagrant 7970 Dec 16 20:33 _custom_ide_helper.php
0 drwxr-xr-x 1 vagrant vagrant 192 Dec 12 16:40 database
8 -rw-r--r-- 1 vagrant vagrant 6148 Dec 14 16:31 .DS_Store
4 -rw-r--r-- 1 vagrant vagrant 627 Dec 4 12:34 .env
4 -rw-r--r-- 1 vagrant vagrant 499 Dec 4 17:29 .env.example
0 drwxr-xr-x 1 vagrant vagrant 480 Dec 18 14:02 .git
4 -rw-r--r-- 1 vagrant vagrant 61 Nov 21 09:24 .gitattributes
4 -rw-r--r-- 1 vagrant vagrant 154 Nov 21 09:24 .gitignore
4 -rw-r--r-- 1 vagrant vagrant 1278 Dec 14 08:58 .gitlab-ci.yml
4 -rw-r--r-- 1 vagrant vagrant 2389 Dec 18 00:10 gruntfile.js
4 -rw-r--r-- 1 vagrant vagrant 335 Dec 12 10:26 Homestead.yaml
0 drwxr-xr-x 1 vagrant vagrant 544 Dec 18 14:01 .idea
512 -rw-r--r-- 1 vagrant vagrant 464272 Dec 18 13:53 _ide_helper.php
0 drwxr-xr-x 1 vagrant vagrant 24704 Dec 18 00:03 node_modules
4 -rw-r--r-- 1 vagrant vagrant 2164 Dec 18 00:03 package.json
380 -rw-r--r-- 1 vagrant vagrant 385087 Dec 18 00:03 package-lock.json
128 -rw-r--r-- 1 vagrant vagrant 93326 Dec 18 13:53 .phpstorm.meta.php
4 -rw-r--r-- 1 vagrant vagrant 1190 Dec 15 10:28 phpunit.xml
0 drwxr-xr-x 1 vagrant vagrant 320 Dec 12 12:34 public
4 -rw-r--r-- 1 vagrant vagrant 855 Dec 12 10:26 readme.md
0 drwxr-xr-x 1 vagrant vagrant 160 Nov 21 09:24 resources
0 drwxr-xr-x 1 vagrant vagrant 128 Dec 17 16:57 routes
4 -rw-r--r-- 1 vagrant vagrant 563 Nov 21 09:24 server.php
0 drwxrwxr-x 1 vagrant vagrant 256 Dec 18 13:50 storage
0 drwxr-xr-x 1 vagrant vagrant 224 Dec 17 13:42 tests
0 drwxr-xr-x 1 vagrant vagrant 96 Dec 18 13:27 .vagrant
4 -rw-r--r-- 1 vagrant vagrant 1376 Nov 21 09:24 Vagrantfile
0 drwxr-xr-x 1 vagrant vagrant 1280 Dec 18 13:25 vendor
204 -rw-r--r-- 1 vagrant vagrant 208270 Dec 18 13:50 yarn.lock
I've figured it out, for some reason in my /bootstrap/cache directory, laravel was referencing paths on my host machine instead of my vagrant box, clearing this directory did the trick for me. For some reason php artisan cache:clear didn't clear these files.
I've also set up a provisioning script to delete these files for me everytime i provision my Vagrant Box.
# Remove Cache Files (because old cache files can cause issues from time to time) [Keep .gitignore in all Directories]
sudo find "$APPPATH/bootstrap/cache" ! -name '.gitignore' -type f -exec rm -f {} +
sudo find "$APPPATH/storage/framework/cache" ! -name '.gitignore' -type f -exec rm -f {} +
sudo find "$APPPATH/storage/framework/sessions" ! -name '.gitignore' -type f -exec rm -f {} +
sudo find "$APPPATH/storage/framework/testing" ! -name '.gitignore' -type f -exec rm -f {} +
sudo find "$APPPATH/storage/framework/views" ! -name '.gitignore' -type f -exec rm -f {} +

linux PATH not working

I dont know why rbenv command do not work.. T^T
only work when 'cd /usr/local/.rbenv/bin && ./rbenv'
myggul#ubuntu:~$ echo $PATH
/usr/local/java/bin:/usr/local/.rbenv/bin;/home/myggul/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
myggul#ubuntu:~$ cd /usr/local/.rbenv/bin
myggul#ubuntu:/usr/local/.rbenv/bin$ ll
total 12
drwxrwxr-x 2 myggul myggul 4096 Jul 16 16:11 ./
drwxr-xr-x 7 myggul myggul 4096 Jul 16 16:11 ../
lrwxrwxrwx 1 myggul myggul 16 Jul 16 16:11 rbenv -> ../libexec/rbenv*
-rwxrwxr-x 1 myggul myggul 724 Jul 16 16:11 ruby-local-exec*
myggul#ubuntu:/usr/local/.rbenv/bin$ rbenv
The program 'rbenv' is currently not installed. You can install it by typing:
sudo apt-get install rbenv
myggul#ubuntu:/usr/local/.rbenv/bin$ cd ~
myggul#ubuntu:~$ rbenv
The program 'rbenv' is currently not installed. You can install it by typing:
sudo apt-get install rbenv
You have a semicolon in your PATH which should be a colon.

Can't run npm-installed packages as user

Earlier this afternoon I installed Node.js on Fedora 16.
user#$ sudo yum localinstall --nogpgcheck http://nodejs.tchol.org/repocfg/fedora/nodejs-stable-release.noarch.rpm
user#$ sudo yum install nodejs-compat-symlinks npm
Then I installed a package with npm. Every package I've installed with npm on Fedora (this isn't my first time) has involved something like the following process. Read it and weep. Clearly, this is hackish and wrong, but when I decide to install less or any other npm package, I have to go through the same procedure. Why? What is broken about my environment or approach?
user#$ sudo npm install -g jslint
[... this works ... kind of]
user#$ jslint
bash: jslint: command not found
user#$ sudo su
root#$ jslint
No files specified.
Usage: /bin/jslint ... [works]
root#$ which jslint
/bin/jslint
root#$ ls -l jslint
lrwxrwxrwx. 1 root root 38 Jul 15 14:58 /bin/jslint -> /lib/node_modules/jslint/bin/jslint.js
root#$ cd /lib/node_modules; ls -l
...
drwxr-xr-x. 2 root root 4096 Jul 15 14:22 inherits
drwxr-xr-x. 2 root root 4096 Jul 15 14:22 ini
drwx------. 6 nobody usergroup 4096 Jul 15 14:58 jshint
drwxr-xr-x. 3 root root 4096 Jul 15 14:22 lru-cache
...
root#$ find . -type d -print0 | xargs -0 chmod 755
root#$ ls -l
...
drwxr-xr-x. 2 root root 4096 Jul 15 14:22 inherits
drwxr-xr-x. 2 root root 4096 Jul 15 14:22 ini
drwxr-xr-x. 5 nobody usergroup 4096 Jul 15 15:32 jslint
drwxr-xr-x. 3 root root 4096 Jul 15 14:22 lru-cache
...
root#$ su user
user#$ jslint
o files specified.
Usage: /bin/jslint [now it finally works]
Recent versions of npm switch to user "nobody" as a security measure if it's being run with sudo privileges. Try doing global installs while logged in as root, rather than using sudo.

Resources