【发布时间】:2018-03-11 08:23:50
【问题描述】:
这就是我的 Dockerfile 的样子。如您所见,我正在尝试安装meteorJS、standardJS 和一些npm 包。
FROM ubuntu:latest
# build arguments
ARG APP_PACKAGES
ARG APP_LOCALE=en_US
ARG APP_CHARSET=UTF-8
ARG APP_USER=app
ARG APP_USER_DIR=/home/${APP_USER}
# add packages for building NPM modules (required by Meteor)
RUN apt-get update -y
RUN apt-get -y dist-upgrade
RUN apt-get install -yqq \
python \
build-essential \
apt-transport-https \
ca-certificates \
curl \
locales \
nodejs \
npm \
nodejs-legacy \
sudo \
git
RUN apt-get autoremove
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
# set the locale (required by Meteor)
RUN locale-gen ${APP_LOCALE}
RUN localedef ${APP_LOCALE}.${APP_CHARSET} -i ${APP_LOCALE} -f ${APP_CHARSET}
# create a non-root user that can write to /usr/local (required by Meteor)
RUN useradd -mUd ${APP_USER_DIR} ${APP_USER}
RUN chown -Rh ${APP_USER} /usr/local
USER ${APP_USER}
# MeteorJS
RUN curl https://install.meteor.com/ | sh
# StandardJS
RUN npm install -g standard
# NPM packages
RUN npm install gridfs-stream gm fluent-ffmpeg
但最后一行似乎有一些问题,因为我无法安装 npm 包。
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.
npm ERR! Linux 4.4.0-31-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "gridfs-stream" "gm" "fluent-ffmpeg"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! path /
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
一开始我设置了一个非root用户,必须这样做才能让meteorJS工作。但这确实给最后一行带来了问题......
npm ERR! Error: EACCES: permission denied, access '/'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, access '/'] errno: -13, code: 'EACCES', syscall: 'access', path: '/' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 4.4.0-31-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "gridfs-stream" "gm" "fluent-ffmpeg"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! path npm-debug.log.4105014794
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.4105014794'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, open 'npm-debug.log.4105014794']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: 'npm-debug.log.4105014794' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
【问题讨论】:
-
也许,您忘记了
-g选项? -
旁注:我推荐使用官方节点镜像node:8.6,而不是使用
ubuntu:latest。