EACCES: permission denied, open '/usr/local/lib/node_modules/npm/bin/npm-cli.js'

后端 未结 3 2008
眼角桃花
眼角桃花 2021-01-24 06:16

Hello sir i am new to docker, i am using ubuntu budgie(linux) 20.04 my docker version is Docker version 18.09.9, build 1752eb3 i have install docker using snap pac

相关标签:
3条回答
  • 2021-01-24 06:42

    Please try to use yarn instead of node.

    FROM node:10 
    USER root 
    WORKDIR /home/node/app 
    COPY package.json . 
    RUN yarn install 
    
    0 讨论(0)
  • 2021-01-24 06:51

    I had the same problem and i tried several solution but the only one how did work is to change docker version

    docker-ce|5:18.09.0~3-0~ubuntu-bionic|https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
    docker-ce|18.06.3~ce~3-0~ubuntu|https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
    docker-ce|18.06.2~ce~3-0~ubuntu|https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
    

    i was using 5:19.03.9~3-0~ubuntu-bionicand i switched to 18.06.3~ce~3-0~ubuntu

    I kept the same Dockerfile config :

    FROM node:10 
    USER root 
    WORKDIR /home/node/app 
    COPY package.json . 
    RUN npm install 
    
    # Bundle app source COPY . /app
    
    EXPOSE 8080  CMD [ "node", "server.js" ]
    

    it returns :

    Step 5/8 : RUN npm install
    ---> Running in 5b6cd0a9a7cd
    npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
    npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
    npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
    npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
    npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
    
    > nodemon@1.19.4 postinstall /home/node/app/node_modules/nodemon
    > node bin/postinstall || exit 0
    
    Love nodemon? You can now support the project via the open collective:
    > https://opencollective.com/nodemon/donate
    
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    npm WARN quiz-service@1.0.0 No description
    npm WARN quiz-service@1.0.0 No repository field.
    
    added 322 packages from 227 contributors and audited 323 packages in 21.573s
    
    1 package is looking for funding
    run `npm fund` for details
    
    found 0 vulnerabilities
    
    Removing intermediate container 5b6cd0a9a7cd
    ---> cc344027e126
    Step 6/8 : COPY . /app
    ---> 10841d9cf0bf
    Step 7/8 : EXPOSE 8080
    

    you can check this link for more detail on reinstalling docker

    0 讨论(0)
  • 2021-01-24 06:55

    This error originates from the fact, that your current user does not have enough permission to access the npm cli file.

    Did you try the minimal Dockerfile:

    FROM node:lts
    
    WORKDIR /home/node
    COPY . .
    RUN npm install
    
    CMD ['npm', 'start']
    

    Does it work for you? If so, the problem in your Dockerfile, I assume in user node or you have some other script we don't see in OP.

    0 讨论(0)
提交回复
热议问题