jansmolders86 / mediacenterjs

A HTML/CSS/Javascript (NodeJS) based Media center
http://mediacenterjs.com
1.29k stars 243 forks source link

npm install : "node-pre-gyp: Permission denied" and sqlite3 #191

Closed Spriteware closed 9 years ago

Spriteware commented 9 years ago

Hi,

I was trying to install mediacenterjs, but npm install doesn't work correctly. Here is the error I get :

francois@francois-N550JV:/media/francois/Partage/www/mediacenterjs$ npm install
npm WARN package.json moviedb@0.1.9 No repository field.
-
> sqlite3@3.0.5 install /media/francois/Partage/www/mediacenterjs/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

sh: 1: node-pre-gyp: Permission denied
npm ERR! Linux 3.16.0-30-generic
npm ERR! argv "node" "/usr/bin/npm" "install"
npm ERR! node v0.10.33
npm ERR! npm  v2.5.0
npm ERR! code ELIFECYCLE

npm ERR! sqlite3@3.0.5 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the sqlite3@3.0.5 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls sqlite3
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /media/francois/Partage/www/mediacenterjs/npm-debug.log

First I taught the problem was from a missing installation of sqlite, so I did sudo apt-get install sqlite3, but definitively the main problem seems to be node-pre-gyp: Permission denied I tried to execute npm install as root, but it doesn't fix anything. I also tried to execute npm install --unsafe-perms according to my research on stackoverflow, but it doesn't fix anything too.

Do you have any solution ?

Thank you, Spriteware

hoffi commented 9 years ago

Hey, i also had the same problem but sudo npm install worked for me. However, have no idea why this happens..

jansmolders86 commented 9 years ago

@Spriteware , Did @hoffi 's solution work for you?

Spriteware commented 9 years ago

@jansmolders86 Nope, I had tried it but it did not work...

jansmolders86 commented 9 years ago

@Spriteware what about a npm install node-gyp?

dashko commented 9 years ago

Same issue here.

$ npm install

pre-processor@0.0.1 preinstall /home/dash/IdeaProjects/DizP/v2/preprocessor node bin/preinstall.js

npm WARN package.json app@1.0.0 No description npm WARN package.json app@1.0.0 No repository field. npm WARN package.json app@1.0.0 No README data \

sqlite3@3.0.5 install /home/dash/IdeaProjects/DizP/v2/preprocessor/lib/app/node_modules/sqlite3 node-pre-gyp install --fallback-to-build

sh: /home/dash/IdeaProjects/DizP/v2/preprocessor/lib/app/node_modules/sqlite3/node_modules/.bin/node-pre-gyp: Permission denied npm ERR! Linux 3.14.37-gentoo npm ERR! argv "node" "/usr/bin/npm" "i" npm ERR! node v0.10.30 npm ERR! npm v2.9.0 npm ERR! code ELIFECYCLE

npm ERR! sqlite3@3.0.5 install: node-pre-gyp install --fallback-to-build npm ERR! Exit status 126 npm ERR! npm ERR! Failed at the sqlite3@3.0.5 install script 'node-pre-gyp install --fallback-to-build'. npm ERR! This is most likely a problem with the sqlite3 package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-pre-gyp install --fallback-to-build npm ERR! You can get their info via: npm ERR! npm owner ls sqlite3 npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /home/dash/IdeaProjects/DizP/v2/preprocessor/lib/app/npm-debug.log npm WARN package.json app@1.0.0 No description npm WARN package.json app@1.0.0 No repository field. npm WARN package.json app@1.0.0 No README data

jansmolders86 commented 9 years ago

Did you try "sudo install npm"? Really seems like a permission issue

dashko commented 9 years ago

I think it is a npm bug. I have a partition, which is mounted to /home/dash. Take a look at /etc/fstab:

    /dev/mapper/data    /home/dash  ext4        rw,user,exec 0 0

I found out on the Internet that the problem might cause the user attribute. So, I changed the line in /etc/fstab to:

    /dev/mapper/data    /home/dash  ext4        rw,exec 0 0

And it started to work. However, the permissions are still the same in the both cases.

jansmolders86 commented 9 years ago

Super weird! To bad it isn't directly MCJS related or I could have tried to fix it. Glad you got your answer though!

Thanks again!

dvergeylen commented 8 years ago

Had the same issue here. Could solve it by installing node-pre-gyp module first.

npm install sqlite3

> sqlite3@3.1.2 install /media/D/project/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

sh: 1: node-pre-gyp: Permission denied
install → rollbackFailedO
[...] Truncated [...]

dv@daniel-zenbook /media/D/project $ npm install -g node-pre-gyp
/home/dv/.nvm/versions/node/v5.5.0/bin/node-pre-gyp -> /home/dv/.nvm/versions/node/v5.5.0/lib/node_modules/node-pre-gyp/bin/node-pre-gyp
/home/dv/.nvm/versions/node/v5.5.0/lib
└── node-pre-gyp@0.6.24 

dv@daniel-zenbook /media/D/project $ npm install sqlite3 --save-dev

> sqlite3@3.1.2 install /media/D/project/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

[sqlite3] Success: "/media/D/project/node_modules/sqlite3/lib/binding/node-v47-linux-x64/node_sqlite3.node" is installed via remote
Project@0.0.1 /media/D/project
└─┬ sqlite3@3.1.2 
  └── nan@2.2.0 

npm WARN EPACKAGEJSON Project@0.0.1 No description
npm WARN EPACKAGEJSON Project@0.0.1 No repository field.
npm WARN EPACKAGEJSON Project@0.0.1 No license field.
dv@daniel-zenbook /media/D/project $ 

Hope this helps!

jansmolders86 commented 8 years ago

Thanks @dvergeylen!!

michael1389 commented 7 years ago

hello,@dvergeylen: I had the same issue with you when i did: npm install sqlite3 on windows 7. But it does not work with your method?

dvergeylen commented 7 years ago

Hi @michael1389,

I am afraid I can't help you here as I don't have a Windows setup where I installed npm. :-(

michael1389 commented 7 years ago

@dvergeylen: Hey, i had soved it! I just did :uninstall the node-v4.5.0-x64 ,clear the folder of node_modules,then install the node-v6.10.0-x64,npm install sqlite3 --save,wait a minute...

thank you all the same!

jansmolders86 commented 7 years ago

Woot! That's excellent!

FradSer commented 7 years ago

It works for me:

npm config set user 0
npm config set unsafe-perm true
tzs007 commented 7 years ago

@dvergeylen you is teh man! https://media.giphy.com/media/iiS84hOJXh1Pq/giphy.gif

isathish commented 6 years ago

Hi all, following this commend working fine...:) #npm install -g node-gyp node-pre-gyp or $sudo npm install -g node-gyp node-pre-gyp

kidandcat commented 6 years ago

I just used Yarn

bogdanstoica35 commented 5 years ago

It works for me:

npm config set user 0
npm config set unsafe-perm true

Thanks, it works for me as well!

insoluzioni commented 5 years ago

I was accessing Debian 6 VM via SSH, sudo npm install didn't work for me. Solution was to login SSH as root user: https://linuxconfig.org/enable-ssh-root-login-on-debian-linux-server And then using the su command.

zeex124 commented 5 years ago

Well can someone explain to me how this work :

i runned npm install sqlite3 as root got permision denied sudo install sqlite3 as root worked... why did i got a perm denied as root but root+sudo worked? mystery

luojunyuan commented 4 years ago

It works for me:

npm config set user 0
npm config set unsafe-perm true

worked fine with yarn😊!

walter-clayton commented 4 years ago

This one worked for me for some reason ¯_(ツ)_/¯ npm install --unsafe-perms

codekaze commented 3 years ago

Hi all, following this commend working fine...:) #npm install -g node-gyp node-pre-gyp or $sudo npm install -g node-gyp node-pre-gyp

this one works for me!!!

MHamzaRajput commented 1 year ago

Hi all, following this commend working fine...:) #npm install -g node-gyp node-pre-gyp or $sudo npm install -g node-gyp node-pre-gyp

worked for me.

aikar commented 1 year ago

Note: adding unsafe-perm is sketchy in that the root issue is running npm install as root, going to end up running compilers and such as root which can be dangerous.

I ran it as a sub user but then also started having problems with command not found, but I was able to solve that by adding ./node_modules/.bin to PATH (the . is important so it also finds it within sub folders too)

I am not fully sure why its having problems without this in path but it's all I had to do to get it working

my nvm-runner does:

    if [ -z "${NVM_DIR-}" ]; then
        export NVM_DIR=~/.nvm
    fi
    export PATH="./node_modules/.bin:$PATH"
    NVM_RUNNER_REALPATH=$(realpath "${BASH_SOURCE[0]}");
    LOCAL_DIR=$(dirname "$NVM_RUNNER_REALPATH")

    if [ -z "$NODE_VERSION" ]; then
        NODE_VERSION=$(cat .nvmrc)
    fi

    export NODE_VERSION

    . "${LOCAL_DIR}/nvm.sh" --no-use
    if [ ! -d "${NVM_DIR}/versions/node/v${NODE_VERSION}" ]; then
        nvm install --no-progress "${NODE_VERSION}"
    else
        nvm use --silent "${NODE_VERSION}"
    fi
    # strip yarn - it injects node that overrides
    NEW_PATH=$(echo "$PATH" | sed -e "s/\\/tmp\\/yarn\d*-[^\:]*://g")
    export PATH="$NEW_PATH"
    exec "$@"

Then invoked like this was giving me issues without -u node then even with got command not found. sudo -u node -H node_modules/.bin/nvm-runner npm rebuild --update-binary

So hopefully this helps people solve this better than the hacky ways suggested above.

Installing pre-gyp globally is a hacky workaround, as you now introduce risk that the pre gyp its running with isn't same version/compat as the one the project defined.

mdietrich commented 1 year ago

Just in case... I had the same problem and @dashko led me to the right solution. The path containing the node_modules was mounted from an external disk and missing the "exec" option in fstab so that the call of an executable during installation could noch succeed. After adding "exec" and remounting everything worked as expected.