How to prevent npm from installing demo/sample/example/test code for a package? - node.js

Is there a way to have npm not install certain elements of a package? Like tests or example/demo code?
For example, in my test-api project, a package that I'm using has a dependency called jmespath:
user#hostname MINGW64 ~/Projects/test-api/node_modules/jmespath (develop)
$ ll
total 109
drwxr-xr-x 1 user group 0 May 15 00:16 ./
drwxr-xr-x 1 user group 0 May 15 00:17 ../
-rw-r--r-- 1 user group 126 Apr 25 2014 .eslintrc
-rw-r--r-- 1 user group 13 Apr 10 2014 .npmignore
-rw-r--r-- 1 user group 71 Jul 22 2015 .travis.yml
drwxr-xr-x 1 user group 0 May 15 00:16 artifacts/
-rw-r--r-- 1 user group 932 Feb 29 2016 BASELINE
-rw-r--r-- 1 user group 443 Jul 22 2015 bower.json
-rwxr-xr-x 1 user group 270 Feb 15 2016 g.sh*
-rw-r--r-- 1 user group 855 Mar 25 2016 Gruntfile.js
-rw-r--r-- 1 user group 3130 Apr 25 2014 index.html
-rw-r--r-- 1 user group 105 Apr 28 2014 james.html
-rw-r--r-- 1 user group 58310 Mar 25 2016 jmespath.js
-rwxr-xr-x 1 user group 535 Feb 13 2016 jp.js*
-rw-r--r-- 1 user group 4645 Feb 29 2016 l.js
-rw-r--r-- 1 user group 559 Jul 22 2015 LICENSE
-rw-r--r-- 1 user group 1802 May 15 00:16 package.json
-rw-r--r-- 1 user group 1229 Mar 25 2016 perf.js
-rw-r--r-- 1 user group 2011 Jul 22 2015 README.md
-rw-r--r-- 1 user group 151 Feb 13 2016 reservedWords.json
drwxr-xr-x 1 user group 0 May 15 00:16 test/
Here index.html is a demo app and test directory contains tests. If I do not want these in the node_modules directory, is there a way to exclude them during npm install?

No, the whole git repository of the dependency package is downloaded and then the package's dependencies are installed too from their package.json, all this information is stored in your package-lock.json.

Related

SSH 'server refused our key' when using home directory on external EBS volume

Scenario;
AWS EC2 running Red Hat 8.2 with an EBS volume mounted at /data
mount | grep -i data
/dev/nvme1n1 on /data type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
Created a test user with home directory on the external EBS volume /data/home/test and copied authorized_keys from ec2-user. SSH fails, 'Server refused our key'. However, when the home directory is moved to root volume; /home, it is possible to login.
The permissions are the same, what am I missing? Thanks!
# ls -Rla /data/home/test/
/data/home/test/:
total 16
drwx------. 3 test test 88 Oct 19 10:16 .
drwxr-xr-x. 4 root root 30 Oct 19 10:15 ..
-rw-r--r--. 1 test test 18 Aug 30 2019 .bash_logout
-rw-r--r--. 1 test test 141 Aug 30 2019 .bash_profile
-rw-r--r--. 1 test test 312 Aug 30 2019 .bashrc
-rw-r--r--. 1 test test 172 Feb 6 2020 .kshrc
drwx------. 2 test test 29 Oct 19 10:16 .ssh
/data/home/test/.ssh:
total 4
drwx------. 2 test test 29 Oct 19 10:16 .
drwx------. 3 test test 88 Oct 19 10:16 ..
-rw-------. 1 test test 829 Oct 19 10:16 authorized_keys
# ls -Rla /home/test/
/home/test/:
total 16
drwx------. 3 test test 88 Oct 19 10:40 .
drwxr-xr-x. 8 root root 106 Oct 19 10:39 ..
-rw-r--r--. 1 test test 18 Aug 30 2019 .bash_logout
-rw-r--r--. 1 test test 141 Aug 30 2019 .bash_profile
-rw-r--r--. 1 test test 312 Aug 30 2019 .bashrc
-rw-r--r--. 1 test test 172 Feb 6 2020 .kshrc
drwx------. 2 test test 29 Oct 19 10:40 .ssh
/home/test/.ssh:
total 4
drwx------. 2 test test 29 Oct 19 10:40 .
drwx------. 3 test test 88 Oct 19 10:40 ..
-rw-------. 1 test test 829 Oct 19 10:40 authorized_keys

Linux folder permissions not inherited with symfony new project

I'm setting up a new web server, and getting some issues with folder perms when generating a new symfony project.
All my websites are located into /var/www
My symfony installer is located in /usr/local/bin/symfony
And this my my symfony installer ownership and perms:
-rwxr-xr-x 1 root staff 233229 Oct 11 00:56 symfony
Here is what I did on my website main folder :
chown :www-data /var/www/
chmod g+s /var/www/
setfacl u:my-user:rwx,d:u:my-user:rwx,g:www-data:rwx,d:g:www-data:rwx /var/www
When uploading file, everything is fine, group and perms are inherited correctly.
The problem is when I generate a new symfony project with the following command while located into /var/www:
symfony new my_project
This is the project folder perms:
drwxr-xr-x 9 501 root 4096 Oct 15 00:20 test
And the perms inside the project folder:
drwxr-xr-x 4 501 staff 4096 Oct 15 00:20 app
drwxr-xr-x 2 501 staff 4096 Oct 15 00:20 bin
-rw-rw-rw- 1 root root 2032 Oct 15 00:20 composer.json
-rw-rw-rw- 1 root root 74614 Oct 15 00:20 composer.lock
-rw-rw-rw- 1 root root 248 Oct 15 00:20 .gitignore
-rw-r--r-- 1 501 staff 978 Oct 3 21:12 phpunit.xml.dist
-rw-rw-rw- 1 root root 68 Oct 15 00:20 README.md
drwxr-xr-x 3 501 staff 4096 Oct 15 00:20 src
drwxr-xr-x 3 501 staff 4096 Oct 15 00:20 tests
drwxr-xr-x 5 501 staff 4096 Oct 15 00:20 var
drwxr-xr-x 15 501 root 4096 Oct 15 00:20 vendor
drwxr-xr-x 3 501 staff 4096 Oct 3 21:14 web
ACL aren't inherited at all.
After a lookup, 501 seems to be the daemon user.
How can I fix this issue?
You need to use recursive Preciel.
Try:
setfacl -R ...
Also the commands you used sets the permission for /var/www, but nothing underneath that!

OSX Homebrew /usr/local permisions for node

I have installed homebrew without any problems.
The problem was to install node.. I got permission errors about /usr/local directory and symlinks.
So I did
sudo chown -R myuser /usr/local
then I istalled node without problems and then I did
sudo chown -R root /usr/local
I don't remember how was the owners in first place. I just followed some suggestions from stackoverflow to change the owner of /usr/local (a voice inside me says I did bad).
So when I run
brew doctor
I got some warnings and suggestions to chown some folders in /usr/local directory, so I did them. Then when I run
brew doctor
brew update
I get no warnings or errors anymore and looks fine (there was no updates to do after all).
My directories now looks like below. Can anyone confirm if is secure like that? How should be the owners in /usr/local ? Tt's okay to have it owned by my user as they say at github? Thanks.
myuser#iMac:/usr$ ls -la
total 8
drwxr-xr-x# 12 root wheel 408B Sep 30 23:52 ./
drwxr-xr-x 30 root wheel 1.1K Jan 23 17:51 ../
drwxr-xr-x 5 root wheel 170B Aug 23 03:51 X11/
lrwxr-xr-x 1 root wheel 3B Sep 30 23:43 X11R6# -> X11
drwxr-xr-x 3 root wheel 102B Aug 27 04:17 adic/
drwxr-xr-x 1055 root wheel 35K Jan 23 17:51 bin/
drwxr-xr-x 263 root wheel 8.7K Jan 23 17:52 lib/
drwxr-xr-x 186 root wheel 6.2K Jan 23 17:51 libexec/
drwxrwxr-x 22 root admin 748B Feb 7 12:28 local/
drwxr-xr-x 243 root wheel 8.1K Jan 23 17:51 sbin/
drwxr-xr-x 45 root wheel 1.5K Sep 30 23:43 share/
drwxr-xr-x 4 root wheel 136B Sep 17 09:03 standalone/
myuser#iMac:/usr$ cd local/
myuser#iMac:/usr/local$ ls -la
total 104
drwxrwxr-x 22 root admin 748B Feb 7 12:28 ./
drwxr-xr-x# 12 root wheel 408B Sep 30 23:52 ../
drwxr-xr-x 15 myuser admin 510B Feb 7 12:56 .git/
-rw-r--r-- 1 root admin 847B Feb 6 10:48 .gitignore
-rw-r--r-- 1 root admin 1.3K Feb 6 10:48 .travis.yml
-rw-r--r-- 1 root admin 291B Feb 6 10:48 .yardopts
-rw-r--r-- 1 root admin 3.1K Feb 6 10:48 CODEOFCONDUCT.md
-rw-r--r-- 1 root admin 2.5K Feb 6 10:48 CONTRIBUTING.md
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 Cellar/
-rw-r--r-- 1 root admin 1.2K Feb 6 10:48 LICENSE.txt
drwxr-xr-x 10 myuser admin 340B Feb 7 12:28 Library/
-rw-r--r-- 1 root admin 2.4K Feb 6 10:48 README.md
-rw-r--r-- 1 root admin 23K Feb 6 10:48 SUPPORTERS.md
drwxrwxr-x 9 root admin 306B Feb 7 12:28 bin/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 etc/
drwxr-xr-x 10 root wheel 340B Aug 3 2015 git/
drwxr-xr-x 20 root wheel 680B Dec 3 02:01 go/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 include/
drwxr-xr-x 4 myuser admin 136B Feb 7 12:28 lib/
drwxr-xr-x 3 root wheel 102B May 15 2015 n/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 opt/
drwxrwxr-x 5 root admin 170B Feb 7 12:28 share/
myuser#iMac:/usr/local$

Reading package lists... Error! on EC2

I am running Ubuntu 14.04.1 LTS on a t1.micro on ec2. Just a moment ago I logged in, ran sudo apt-get update and got Reading package lists... Error!
I also realized that I no longer can install packages using sudo apt-get install.
Any idea what went wrong here? And how to fix it?
I have tried the answer suggested in this thread https://unix.stackexchange.com/questions/139441/reading-package-lists-error but that did not fix the problem. What makes things a little annoying also is the lack of error logs (or the fact I do not know where to look). For example the sudo apt-get install just fails and I do not know how to run it in verbose mode or where to look to find the specific reason why it is failing...
Here is the content of /var/lib/apt/lists
total 105476
drwxr-xr-x 3 root root 4096 Mar 15 23:05 .
drwxr-xr-x 6 root root 4096 Mar 9 05:58 ..
-rw-r----- 1 root root 0 Mar 15 20:02 lock
drwxr-xr-x 2 root root 4096 Mar 15 23:05 partial
-rw-r--r-- 1 root root 822 Mar 15 19:23 pkg.jenkins-ci.org_debian_binary_Packages
-rw-r--r-- 1 root root 2046 Mar 15 19:23 pkg.jenkins-ci.org_debian_binary_Release
-rw-r--r-- 1 root root 181 Mar 15 19:23 pkg.jenkins-ci.org_debian_binary_Release.gpg
-rw-r--r-- 1 root root 19466 Mar 13 10:29 ppa.launchpad.net_webupd8team_java_ubuntu_dists_trusty_main_binary-amd64_Packages
-rw-r--r-- 1 root root 6192 Mar 13 10:29 ppa.launchpad.net_webupd8team_java_ubuntu_dists_trusty_main_i18n_Translation-en
-rw-r--r-- 1 root root 15111 Mar 13 10:29 ppa.launchpad.net_webupd8team_java_ubuntu_dists_trusty_Release
-rw-r--r-- 1 root root 316 Mar 13 10:29 ppa.launchpad.net_webupd8team_java_ubuntu_dists_trusty_Release.gpg
-rw-r--r-- 1 root root 1410166 Mar 12 21:35 security.ubuntu.com_ubuntu_dists_trusty-security_main_binary-amd64_Packages
-rw-r--r-- 1 root root 1140580 Mar 11 00:34 security.ubuntu.com_ubuntu_dists_trusty-security_main_i18n_Translation-en
-rw-r--r-- 1 root root 349379 Mar 12 21:40 security.ubuntu.com_ubuntu_dists_trusty-security_main_source_Sources
-rw-r--r-- 1 root root 61968 Mar 12 21:40 security.ubuntu.com_ubuntu_dists_trusty-security_Release
-rw-r--r-- 1 root root 933 Mar 12 21:40 security.ubuntu.com_ubuntu_dists_trusty-security_Release.gpg
-rw-r--r-- 1 root root 542657 Mar 12 21:35 security.ubuntu.com_ubuntu_dists_trusty-security_universe_binary-amd64_Packages
-rw-r--r-- 1 root root 250304 Mar 11 00:34 security.ubuntu.com_ubuntu_dists_trusty-security_universe_i18n_Translation-en
-rw-r--r-- 1 root root 72494 Mar 12 21:40 security.ubuntu.com_ubuntu_dists_trusty-security_universe_source_Sources
-rw-r--r-- 1 root root 8234934 May 8 2014 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty_main_binary-amd64_Packages
-rw-r--r-- 1 root root 4149211 Apr 15 2014 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty_main_i18n_Translation-en
-rw-r--r-- 1 root root 5000095 May 8 2014 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty_main_source_Sources
-rw-r--r-- 1 root root 58512 May 8 2014 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty_Release
-rw-r--r-- 1 root root 933 May 8 2014 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty_Release.gpg
-rw-r--r-- 1 root root 31726252 May 8 2014 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty_universe_binary-amd64_Packages
-rw-r--r-- 1 root root 18635427 May 8 2014 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty_universe_i18n_Translation-en
-rw-r--r-- 1 root root 27857155 May 8 2014 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty_universe_source_Sources
-rw-r--r-- 1 root root 2881415 Mar 15 22:58 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty-updates_main_binary-amd64_Packages
-rw-r--r-- 1 root root 1784682 Mar 12 18:07 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty-updates_main_i18n_Translation-en
-rw-r--r-- 1 root root 938350 Mar 15 22:58 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty-updates_main_source_Sources
-rw-r--r-- 1 root root 61966 Mar 15 22:58 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty-updates_Release
-rw-r--r-- 1 root root 933 Mar 15 22:58 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty-updates_Release.gpg
-rw-r--r-- 1 root root 1538422 Mar 15 22:58 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty-updates_universe_binary-amd64_Packages
-rw-r--r-- 1 root root 669587 Mar 12 18:27 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty-updates_universe_i18n_Translation-en
-rw-r--r-- 1 root root 510829 Mar 15 22:58 us-west-2.ec2.archive.ubuntu.com_ubuntu_dists_trusty-updates_universe_source_Sources
and a little snippet from /var/lib/dpkg/status
Package: node-normalize-package-data
Status: install ok installed
Priority: extra
Section: web
Installed-Size: 58
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Architecture: all
Version: 0.2.2-1
Depends: nodejs, node-github-url-from-git, node-semver (>= 2)
Description: Normalizes package metadata - Node.js module
This module is used by node-read-package-json to normalize data it
reads from a package.json file typically found in Node.js modules,
but in principle it could come from any source.
.
Node.js is an event-based server-side javascript engine.
Original-Maintainer: Debian Javascript Maintainers <pkg-javascript-devel#lists.alioth.debian.org>
Homepage: https://github.com/meryn/normalize-package-data
A restart of the instance fixed the issue. Why this worked, I cannot explain!
You can try out the below commands to fix the issue
sudo rmdir /var/lib/dpkg/status
sudo touch /var/lib/dpkg/status
sudo apt-get update
The first command will remove the empty directory, second will create the new directory and the last command will populate the lists files.
Also, Restart your EC2 instance to make the above changes effective.

Failure to run postgresql on Mac (after reboot)

Whatever I did I couldn't start postgresql 9.2 on Mac 10.9.3 again after reboot.
$ initdb -D /usr/local/var/postgres
The files belonging to this database system will be owned by user "alex".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres"
I decided I should create another directory in it. So I created data directory there and ran initdb again:
$ initdb -D /usr/local/var/postgres/data
The files belonging to this database system will be owned by user "alex".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/var/postgres/data ... initdb:
could not change permissions of directory "/usr/local/var/postgres/data":
Operation not permitted
I tried to change the permissions but didn't figure out what were the right ones. Here is what I have:
$ ls -ald /usr/local/var/postgres
drwxr-xr-x 22 _postgres staff 748 Jun 13 17:26 /usr/local/var/postgres
ls -ald /usr/local/var/postgres/data
drwxr-xr-x 2 _postgres staff 68 Jun 13 17:26 /usr/local/var/postgres/data
$ ls -al /usr/local/var/postgres
total 96
drwxr-xr-x 22 _postgres staff 748 Jun 13 17:26 .
drwx------ 3 alex admin 102 Jun 1 15:08 ..
-rw------- 1 _postgres _postgres 4 Jun 1 15:08 PG_VERSION
drwx------ 6 _postgres _postgres 204 Jun 2 11:40 base
drwxr-xr-x 2 _postgres staff 68 Jun 13 17:26 data
drwx------ 42 _postgres _postgres 1428 Jun 2 14:18 global
drwx------ 3 _postgres _postgres 102 Jun 1 15:08 pg_clog
-rw------- 1 _postgres _postgres 4465 Jun 2 10:58 pg_hba.conf
-rw------- 1 _postgres _postgres 1636 Jun 1 15:08 pg_ident.conf
drwx------ 4 _postgres _postgres 136 Jun 1 15:08 pg_multixact
drwx------ 3 _postgres _postgres 102 Jun 1 18:24 pg_notify
drwx------ 2 _postgres _postgres 68 Jun 1 15:08 pg_serial
drwx------ 2 _postgres _postgres 68 Jun 1 15:08 pg_snapshots
drwx------ 7 _postgres _postgres 238 Jun 2 21:23 pg_stat
drwx------ 2 _postgres _postgres 68 Jun 2 21:23 pg_stat_tmp
drwx------ 3 _postgres _postgres 102 Jun 1 15:08 pg_subtrans
drwx------ 2 _postgres _postgres 68 Jun 1 15:08 pg_tblspc
drwx------ 2 _postgres _postgres 68 Jun 1 15:08 pg_twophase
drwx------ 4 _postgres _postgres 136 Jun 1 15:08 pg_xlog
-rw------- 1 _postgres _postgres 20571 Jun 1 15:08 postgresql.conf
-rw------- 1 _postgres _postgres 79 Jun 1 18:24 postmaster.opts
-rw------- 1 _postgres _postgres 1482 Jun 2 21:23 server.log
What should I do next? I'm out of ideas. The only guess is that it is related to a file or folder permissions.
Two step process:
Go to your web-browser and search for "postgresql permissions data directory" - look down the list for the page from the official manuals (it's the top one for me).
Read the page from the official manuals and follow the instructions.
Presumably it's complaining that it "could not change permissions" because you aren't running this as user "_postgres". Note - it's normally user "postgres". I don't know if the name-change is something you've done or something common on Mac installations.
Oh - and I can't see why this is tagged "linux"

Resources