Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Anda menentukan dependensi untuk aplikasi Node.js dengan mendeklarasikannya
dalam file package.json.
Misalnya, jika Anda ingin menentukan Lodash
sebagai dependensi, file package.json Anda mungkin akan terlihat seperti berikut:
{"dependencies":{"lodash":"^4.0.1"}}
Anda dapat menggunakan paket Node.js yang kompatibel dengan Linux dengan lingkungan
fleksibel App Engine, termasuk paket yang memerlukan ekstensi native (C).
Selama deployment, runtime Node.js
akan otomatis menginstal
semua dependencies yang dideklarasikan dalam file package.json Anda. Secara default, perintah
npm install digunakan, tetapi pengelola paket Yarn dan Pnpm juga
didukung:
Yarn: Jika file yarn.lock ada, perintah yarn install --production
akan digunakan.
Pnpm: Hanya didukung oleh runtime Node.js
versi 18 dan versi 20 (pratinjau). Jika file pnpm-lock.yaml
ada, perintah pnpm install akan digunakan sebagai gantinya.
Perhatikan bahwa Anda harus memastikan bahwa file yarn.lock atau pnpm-lock.yaml
tidak disertakan di bagian skip_files pada file app.yaml Anda.
Menginstal framework web
Anda harus menggunakan framework web agar aplikasi dapat melayani permintaan web. Anda
dapat menggunakan framework web Node.js apa pun termasuk yang berikut ini:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 UTC."],[[["\u003cp\u003eDependencies for Node.js apps are specified in the \u003ccode\u003epackage.json\u003c/code\u003e file, and the Node.js runtime automatically installs them during deployment.\u003c/p\u003e\n"],["\u003cp\u003eWhile \u003ccode\u003enpm\u003c/code\u003e is used by default, Yarn and Pnpm are also supported, with Yarn using \u003ccode\u003eyarn install --production\u003c/code\u003e if a \u003ccode\u003eyarn.lock\u003c/code\u003e file is present and Pnpm using \u003ccode\u003epnpm install\u003c/code\u003e if a \u003ccode\u003epnpm-lock.yaml\u003c/code\u003e file is present (but only with specific versions of Node.js).\u003c/p\u003e\n"],["\u003cp\u003eAny Linux-compatible Node.js package can be used with the App Engine flexible environment, including those with native C extensions, and web frameworks like Express.js, Hapi.js, and others are supported and must be added to the \u003ccode\u003epackage.json\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eThe Cloud Client Libraries for Node.js provide a way to integrate with Google Cloud services, and can be installed using \u003ccode\u003enpm\u003c/code\u003e, \u003ccode\u003eyarn\u003c/code\u003e, or \u003ccode\u003epnpm\u003c/code\u003e, with the library handling authentication.\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\nYou can use any Linux-compatible Node.js package with App Engine flexible\nenvironment, including packages that require native (C) extensions.\n\nDuring deployment, the Node.js runtime\n[automatically installs](/appengine/docs/flexible/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: Supported only by Node.js runtimes\n version 18 and version 20 (preview). 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\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."]]