Google App Engine上的专用节点模块

如何包含我的node_modules或为私有npm模块指定一个npmlogin/授权令牌?

看来,GAE不再允许node_modules文件夹被包括在内(请参阅此问题 ),并且似乎没有允许npmlogin或设置令牌的挂钩。

如果你在你要部署的应用程序中包含一个本地的.npmrc文件,它将被复制到应用程序源代码中并在npm安装过程中使用。 你可以有一个构build步骤来创build这个文件或从你的主目录复制它。 看到这个npm文章 。

.npmrc文件应该如下所示:

//registry.npmjs.org/:_authToken=<token here> 

我使用的Dockerfile看起来像这样:

 # Use the base App Engine Docker image, based on debian jessie. FROM gcr.io/google_appengine/base # Install updates and dependencies RUN apt-get update -y && apt-get install --no-install-recommends -y -q curl python build-essential git ca-certificates libkrb5-dev && \ apt-get clean && rm /var/lib/apt/lists/*_* # Install the latest release of nodejs RUN mkdir /nodejs && curl https://nodejs.org/dist/v6.2.1/node-v6.2.1-linux-x64.tar.gz | tar xvzf - -C /nodejs --strip-components=1 ENV PATH $PATH:/nodejs/bin COPY . /app/ WORKDIR /app # NODE_ENV to production so npm only installs needed dependencies ENV NODE_ENV production RUN npm install --unsafe-perm || \ ((if [ -f npm-debug.log ]; then \ cat npm-debug.log; \ fi) && false) # start CMD ["npm", "start"]