How to build node projects?

pipeline:
  build:
    image: node:alpine
    commands:
      - npm install -g cnpm
      - cnpm install
      - cd app && cnpm install
      - cd gulp && cnpm install
    when:
      branch: master
+ npm install -g cnpm
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/cnpm failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-08-14T07_20_16_780Z-debug.log

It seems that drone can’t connect to the network.

Is there any special settings missing?

Are you live in China?

That I am. But even with changing the registry, still no luck.

Try

NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node

This mirror site is working for me.

That did not work for me sadly, It seems I have some sort of network issues.
I started the drone like this

version: '2'
services:
 drone-server:
   image: 'drone/drone:0.8'
   ports:
     - 4002:8000
     - 9000
   volumes:
     - '/var/lib/drone:/var/lib/drone/'
   restart: always
   environment:
     - DRONE_OPEN=true
     - DRONE_HOST=http://localhost
     - DRONE_GOGS=true
     - DRONE_GOGS_URL=http://myserver:10080
     - DRONE_SECRET=123456
 drone-agent:
   image: 'drone/agent:0.8'
   depends_on:
     - drone-server
   volumes:
     - '/var/run/docker.sock:/var/run/docker.sock'
   network_mode: host
   environment:
     - DRONE_SERVER=drone-server:9000
     - DRONE_SECRET=123456
     - NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node

My drone.yml is as below

pipeline:
  build:
    image: node:latest
    commands:
      - npm install -g cnpm --registry=https://registry.npm.taobao.org
      - cnpm i
      - cd app && cnpm install
      - cd gulp && cnpm install
    when:
      branch: master
pipeline:
  build:
    image: node:latest
    commands:
      - cd app && npm install --registry=https://registry.npm.taobao.org
      - cd gulp && npm install --registry=https://registry.npm.taobao.org
    when:
      branch: master

don’t set NVM_NODEJS_ORG_MIRROR in your docker-compose.yml

Thanks for the help, but as you can see, changing there registry is not helping.

I even changed the first line into curl http://www.baidu,com, it fails with the error could not resolve host.

I suspect it’s the problem of my docker network setting or Aliyun firewall setting.