No access permission error with npm global install on docker image

前端 未结 5 1828
小鲜肉
小鲜肉 2021-01-31 09:19

I\'m trying to build a docker image with a global install of firebase-tools and angular-cli. I\'m building the same image for two versions of node: 6.x (LTS bor

5条回答
  •  情话喂你
    2021-01-31 09:35

    The problem is because while NPM runs globally installed module scripts as the nobody user, which kinds of makes sense, recent versions of NPM started setting the file permissions for node modules to root. As a result module scripts are no longer allowed to create files and directories in their module.

    See discussion in NPM issue #3849, for some references.

    A simple workaround, which makes sense in a docker environment, is to set the NPM default global user back to root, like so:

    npm -g config set user root
    

    After which you shouldn't have any more EACCES errors.

提交回复
热议问题