Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Specifica le dipendenze per la tua app Node.js dichiarandole nel file package.json.
Ad esempio, se vuoi specificare Lodash come dipendenza, il file package.json potrebbe avere il seguente aspetto:
{"dependencies":{"lodash":"^4.0.1"}}
Puoi utilizzare qualsiasi pacchetto Node.js compatibile con Linux con l'ambiente flessibile di App Engine, inclusi i pacchetti che richiedono estensioni native (C).
Durante il deployment, il runtime Node.js
installa automaticamente
tutte le dependencies dichiarate nel file package.json. Per impostazione predefinita, viene utilizzato il comando npm install, ma sono supportati anche i gestori pacchetti Yarn e Pnpm:
Yarn: se esiste un file yarn.lock, viene utilizzato il comando yarn install --production.
Pnpm: supportato solo dalle versioni 18 e 20 (anteprima) del runtime Node.js. Se esiste un file pnpm-lock.yaml, viene utilizzato il comando pnpm install.
Tieni presente che devi assicurarti che il file yarn.lock o pnpm-lock.yaml non sia specificato nella sezione skip_files del file app.yaml.
Installazione di un framework web
Dovrai utilizzare un framework web per consentire alla tua app di gestire le richieste web. Puoi utilizzare qualsiasi framework web Node.js, tra cui:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 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."]]