Umask setting is ignored by npm for some directories
github.com
github.com
What I observed (even with newest npm 3.10.9) that it sometimes creates node_modules directories with permission 777. when doing the npm install multiple times the results vary, most of the time it results in 755 but sometimes in 777). This seems to have nothing to do with the source tarballs content (retrieved from registry.npmjs.org) but a more general issue. As mentioned, its not deterministic and the tarballs definitively don't contain any files/directories with such permissions.
If that's true, it may take a while to unearth the root cause.
( 95/121) installing grunt-cli [########################################] 100%
warning: directory permissions differ on /usr/bin/
filesystem: 755 package: 777
warning: directory permissions differ on /usr/lib/node_modules/
filesystem: 755 package: 777
:facepalm:
edit: Where "wrong way" is defined as "differently from the target distro's best practices"
So in practice there is a niche that npm covers, that wouldn't be filled if we removed it.
On the question of whether the system package manager should wrap npm - the reason why you want to do so is because it lets npm dependency resolution work regardless of how packages are installed. If the system package manager just does its own thing, then next time you do need to npm install a package (because it's a relatively obscure package that's not in your distro), you don't want it to install copies (or worse, yet overwrite) all the dependencies that you've already installed by other means.
Package managers for scripting languages and similar should be left to manage user-wide packages, or virtualenv-wide for webapps.
package() {
npm install -g --user root --prefix "$pkgdir"/usr "$srcdir"/$pkgname-$pkgver.tgz
rm -r "$pkgdir"/usr/etc
mkdir -p "$pkgdir/usr/share/licenses/$pkgname"
ln -s "../../../lib/node_modules/$pkgname/LICENSE-MIT" "$pkgdir/usr/share/licenses/$pkgname/"
}
[1] https://git.archlinux.org/svntogit/community.git/tree/trunk/...I use npm in a continuous integration/deployment system for a project. The system used to do a git checkout, `npm install` to get the dependencies, and then a build, but then we ran into a few extremely confusing issues where we actually had a couple old dependencies tested and deployed into production because npm install failed to respect the shrinkwrap fully (yet it still exited successfully). We finally had to write a script which compares the node_modules directory against the shrinkwrap, and if there's a mismatch, it removes the entire directory and re-runs `npm install`. Thankfully `npm install` tends to install everything fine from a fresh slate, but it's just soo slow (which is also surprising to me, because shouldn't most everything be cached into ~/.npm if I've installed nearly all of the same dependencies recently? I would think that installing from a shrinkwrap of many things I've installed before would mostly be un-tarring things from cache)...
Unless you have root it's rather difficult to make a directory that the webserver can write to.
It's not specific to PHP, except that PHP is used for web scripting.
The correct way to do it, if you don't have root is:
Make a directory 777 (yes, you do need to). Have the webserver create a subdirectory owned by the webserver. Change the parent directory away from 777 to 755 or 775.
Double check that no one else created something in there while it was wide open.
Be aware that ALL users on that machine who can run web scripts have access to that directory.
An even better way is with mpm-itk
This increased when devops came on the scene, and it was probably one of the first things that made me conclude that devops was about pushing sysadmin skills on unprepared developers. /rant
setfacl -m u:NON-OWNER:rwX,d:u:NON-ONWER:rwX,d:u:OWNER:rwX DIR
(Allows NON-OWNER to read, write, execute if already executable for anyone to that directory, and allows NON-OWNER and OWNER to do the same for newly created files.)The default ACLs make sure that any newly created files can be accessed by both users.