node.js - Google App Engine 上的私有(private) Node 模块

标签 node.js google-app-engine npm

如何包含我的 node_modules 或为私有(private) npm 模块指定 npm 登录/授权 token ?

似乎 GAE 不再允许包含 node_modules 文件夹(参见 this issue )并且似乎没有允许 npm 登录或设置 token 的 Hook 。

最佳答案

如果您在要部署的应用程序本地包含一个 .npmrc 文件,它将被复制到应用程序源中并在 npm 安装期间使用。您可以让构建步骤创建此文件或从您的主目录复制它。参见 this npm article .

.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"]

关于node.js - Google App Engine 上的私有(private) Node 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37780523/

相关文章:

linux - CentOS 错误 - sudo : effective uid is not 0, 是 sudo 安装 setuid root 吗?

javascript - 如何将 MongoDB 查询捕获为字符串并将其显示在我的 Node JS 页面中(使用 mongojs 驱动程序)?

javascript - AWS Lambda 调用函数并不总是返回

node.js - 将 WebDeploy 与 Azure Node 网站结合使用不会触发 npm install

android - 由于 react-native-gesture-handler,无法运行 React Native 项目

javascript - Node "require"提升到脚本外部的顶部 - 失去对外部函数变量的访问

java - Google App Engine 调度程序不会将请求路由到所有可用实例

python - Google App Engine 后台线程与任务

python - 如何使用 GAE Python 下载多个文件

javascript - Grunt 任务陷入无限循环