[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eNode.js application dependencies are managed in the \u003ccode\u003epackage.json\u003c/code\u003e file, where they are declared, and are automatically installed during deployment using \u003ccode\u003enpm install\u003c/code\u003e, \u003ccode\u003eyarn install --production\u003c/code\u003e, or \u003ccode\u003epnpm install\u003c/code\u003e, depending on the presence of a \u003ccode\u003eyarn.lock\u003c/code\u003e or \u003ccode\u003epnpm-lock.yaml\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine supports any Linux-compatible Node.js package and ignores dependencies specified under the \u003ccode\u003edevDependencies\u003c/code\u003e field in the \u003ccode\u003epackage.json\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003ePrivate npm modules can be hosted on Artifact Registry, with the build process automatically handling credentials for deployment, and the registry can be configured in the \u003ccode\u003e.npmrc\u003c/code\u003e or \u003ccode\u003e.yarnrc.yml\u003c/code\u003e files.\u003c/p\u003e\n"],["\u003cp\u003eTo enable an application to serve web requests, a web framework such as Express.js needs to be installed and included in the \u003ccode\u003epackage.json\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eThe Cloud Client Libraries for Node.js, such as the client library for Cloud Storage, can be installed via npm, yarn, or pnpm and provide a way to integrate with Google Cloud services, with authentication handled automatically.\u003c/p\u003e\n"]]],[],null,["# Specifying dependencies\n\nYou specify the dependencies for your Node.js app by declaring\nthem in the `package.json` file.\n\nFor example, if you want to specify [Lodash](https://lodash.com/)\nas a dependency, your `package.json` file might look as follows: \n\n {\n \"dependencies\": {\n \"lodash\": \"^4.0.1\"\n }\n }\n\nDuring deployment, the Node.js runtime\n[automatically installs](/appengine/docs/standard/nodejs/runtime#dependencies)\nall `dependencies` declared in your `package.json` file. By default, the\n`npm install` command is used, however Yarn and Pnpm package managers are also\nsupported:\n\n- Yarn: If a `yarn.lock` file exists, the `yarn install --production`\n command is used instead.\n\n- Pnpm: If a `pnpm-lock.yaml` file\n exists, the `pnpm install` command is used instead.\n\nNote that you must ensure that the `yarn.lock` or `pnpm-lock.yaml` file is\nnot specified in the `skip_files` section of your `app.yaml` file.\n\n\nBy default, App Engine caches fetched dependencies to reduce build\ntimes. To install an uncached version of the dependency, use the command: \n\n gcloud app deploy --no-cache\n\n\u003cbr /\u003e\n\nSupport and limitations for the `package.json` file in the standard\nenvironment:\n\n- You can use any Linux-compatible Node.js package with\n App Engine, including packages that require native (C) extensions.\n\n- If the `engines` field is specified in your `package.json`, you must define a\n [compatible Node.js version](/appengine/docs/standard/nodejs/runtime#nodejs_version).\n\n- All dependencies that you define under the `devDependencies` field are\n ignored and do not get installed for your app in App Engine.\n\n- The `start` script should be lightweight and exclude build steps for the\n best performance because the script runs each time a new instance of your\n application is created.\n\n### Private dependencies with Artifact Registry\n\nIf your app uses a [private npm module](https://docs.npmjs.com/creating-and-publishing-private-packages),\nyou can use an [Artifact Registry Node.js package repository](/artifact-registry/docs/nodejs/store-nodejs)\nto host private dependencies. When deploying your app, the build process\nautomatically generates Artifact Registry credentials for the\n[Cloud Build service account](/build/docs/cloud-build-service-account)\nso you won't need to generate additional credentials.\nTo include private dependencies, list the Artifact Registry repository and\nconfigure settings for authenticating with the registry in your `.npmrc`\nfile in the app directory. For example: \n\n @\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003eSCOPE\u003c/span\u003e\u003c/var\u003e:registry=https://\u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e-npm.pkg.dev/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/\u003cvar translate=\"no\"\u003eREPOSITORY_NAME\u003c/var\u003e\n //\u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e-npm.pkg.dev/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/\u003cvar translate=\"no\"\u003eREPOSITORY_NAME\u003c/var\u003e:always-auth=true\n\nNote that this approach also works for Yarn v1 package manager.\nIf you are using Yarn v2 or higher, list the Artifact Registry repository and\nconfigure settings for authenticating with the registry in your `.yarnrc.yml`\nfile in the app directory. For example: \n\n npmScopes:\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nx\"\u003eSCOPE\u003c/span\u003e\u003c/var\u003e:\n npmRegistryServer: https://\u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e-npm.pkg.dev/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/\u003cvar translate=\"no\"\u003eREPOSITORY_NAME\u003c/var\u003e\n npmAlwaysAuth: true\n\nAfterwards, include your packages in the `package.json` file. For example: \n\n {\n \"dependencies\": {\n \" @\u003cvar translate=\"no\"\u003eSCOPE\u003c/var\u003e/my-package\": \"^1.0.0\"\n }\n }\n\nInstalling a web framework\n--------------------------\n\nYou'll need to use a web framework to enable your app to serve web requests. You\ncan use any Node.js web framework including the following:\n\n- [Express.js](http://expressjs.com/)\n- [Hapi.js](http://hapijs.com/)\n- [Loopback.js](http://loopback.io/)\n- [Koa.js](http://koajs.com/)\n- [Kraken.js](http://krakenjs.com/)\n- [Restify.js](http://restify.com/)\n- [Sails.js](http://sailsjs.org/)\n\nTo use a particular web framework, such as [Express.js](https://expressjs.com/), add the framework to your `package.json` file:\n\n- Using [npm](https://www.npmjs.com/):\n\n ```\n npm install express\n ```\n- Using [yarn](https://yarnpkg.com/):\n\n ```\n yarn add express\n ```\n- Using [pnpm](https://pnpm.io/):\n\n ```\n pnpm add express\n ```\n\nFor example, the resulting `package.json` file might look as follows: \n\n {\n \"dependencies\": {\n \"lodash\": \"^4.0.1\",\n \"express\": \"^4.16.2\"\n }\n }\n\nInstalling the Cloud Client Libraries\n-------------------------------------\n\nThe [Cloud Client Libraries for Node.js](/nodejs/docs/reference)\nis the idiomatic way for Node.js developers to integrate with Google Cloud\nservices, such as [Firestore in Datastore mode (Datastore)](/datastore/docs/reference/libraries)\nand [Cloud Storage](/storage/docs/reference/libraries).\n\nTo install the Node.js client library for Cloud Storage:\n\n1. Install the Cloud Client Libraries locally by using a package manager:\n\n - To use `npm`, run:\n\n ```\n npm install @google-cloud/storage\n ```\n - To use `yarn`, run:\n\n ```\n yarn add @google-cloud/storage\n ```\n - To use `pnpm`, run:\n\n ```\n pnpm add @google-cloud/storage\n ```\n2. Set up authentication. You can configure the Cloud Client Libraries for Node.js\n to [handle authentication automatically](/docs/authentication/client-libraries).\n\n3. Use the [Node.js client library for Cloud Storage](/nodejs/docs/reference/storage/latest)\n reference to implement support for the Cloud Storage service in your\n app."]]