[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eNode.js runtime defaults to executing \u003ccode\u003enpm run build\u003c/code\u003e if a \u003ccode\u003ebuild\u003c/code\u003e script exists in \u003ccode\u003epackage.json\u003c/code\u003e, but you can implement custom build steps.\u003c/p\u003e\n"],["\u003cp\u003eTo define a custom build process, include a \u003ccode\u003egcp-build\u003c/code\u003e script in your \u003ccode\u003epackage.json\u003c/code\u003e file, which will be executed instead of \u003ccode\u003enpm run build\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTo bypass the default \u003ccode\u003enpm run build\u003c/code\u003e execution, add an empty \u003ccode\u003egcp-build\u003c/code\u003e script in \u003ccode\u003epackage.json\u003c/code\u003e as \u003ccode\u003e"gcp-build":""\u003c/code\u003e, or use the environment variable \u003ccode\u003eGOOGLE_NODE_RUN_SCRIPTS\u003c/code\u003e with an empty value.\u003c/p\u003e\n"],["\u003cp\u003eDuring custom build steps, dependencies from both \u003ccode\u003edependencies\u003c/code\u003e and \u003ccode\u003edevDependencies\u003c/code\u003e in \u003ccode\u003epackage.json\u003c/code\u003e are available, but afterwards, App Engine only installs production dependencies listed in \u003ccode\u003edependencies\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eStatic files generated or copied during custom build steps are not served directly by App Engine using \u003ccode\u003estatic_dir\u003c/code\u003e or \u003ccode\u003estatic_files\u003c/code\u003e in \u003ccode\u003eapp.yaml\u003c/code\u003e, and accessing them will result in a \u003ccode\u003e404 NOT FOUND\u003c/code\u003e error.\u003c/p\u003e\n"]]],[],null,["# Running a custom build step\n\nBy default, the node.js runtime will execute `npm run build` if a `build` script\nis detected in `package.json` file. If you require additional control over your build\nsteps before starting your application, you can provide a custom build\nstep. Custom build steps can be executed by adding `gcp-build` in your\n`package.json` file.\n\nTo prevent your build from running the `npm run build` script, you must either:\n\n- Add a `gcp-build` script with an empty value in your `package.json` file: `\"gcp-build\":\"\"`. For details about configuring the `package.json`, see [Node.js buildpacks configurations](/appengine/docs/standard/nodejs/running-custom-build-step#example).\n- Add the [`GOOGLE_NODE_RUN_SCRIPTS`](/docs/buildpacks/nodejs#google_node_run_scripts)\n build environment variable with an empty value in your `app.yaml` file.\n\n build_env_variables:\n GOOGLE_NODE_RUN_SCRIPTS: ''\n\nFor details about specifying build environment variables see [`build_env_variables`](/appengine/docs/standard/reference/app-yaml#runtime_and_app_elements) section in the `app.yaml` file.\n\nWhen this script is executed, the dependencies in the `dependencies` and\n`devDependencies` fields of your `package.json` file are available.\nAfter executing your custom build step, App Engine removes and regenerates the\n`node_modules` folder by only installing the production dependencies declared\nin the `dependencies` field of your `package.json` file.\n\nFor more information on how to configure the runtime for custom build steps,\nsee [Executing custom build steps during deployment](/docs/buildpacks/nodejs#executing_custom_build_steps_during_deployment)\nfor Node.js buildpacks.\n\nExample\n-------\n\nA custom build script can be used for pre-processing tasks, such as\npre-processing CSS, minifying client side JavaScript, or running tools, such as\n`webpack` or `gulp`.\n\nFor example, to compile TypeScript to JavaScript, your `package.json` file might\nlook like the following. Note the `gcp-build` script: \n\n {\n \"name\": \"appengine-typescript\",\n \"description\": \"An example TypeScript app running on Google App Engine.\",\n \"version\": \"0.0.1\",\n \"private\": true,\n \"license\": \"Apache Version 2.0\",\n \"author\": \"Google Inc.\",\n \"engines\": {\n \"node\": \"20.x\"\n },\n \"scripts\": {\n \"prepare\": \"npm run gcp-build\",\n \"pretest\": \"npm run gcp-build\",\n \"test\": \"c8 mocha -p -j 2 test/*.test.js --exit\",\n \"lint\": \"gts lint\",\n \"start\": \"node ./index.js\",\n \"deploy\": \"gcloud app deploy\",\n \"clean\": \"gts clean\",\n \"compile\": \"tsc -p .\",\n \"fix\": \"gts fix\",\n \"build\": \"tsc -p .\",\n \"gcp-build\": \"tsc -p .\"\n },\n \"dependencies\": {\n \"@typescript-eslint/parser\": \"^8.0.0\",\n \"express\": \"^4.16.3\"\n },\n \"devDependencies\": {\n \"@types/express\": \"^4.17.17\",\n \"@types/node\": \"^20.0.0\",\n \"c8\": \"^10.0.0\",\n \"chai\": \"^4.5.0\",\n \"gts\": \"^5.0.0\",\n \"mocha\": \"^10.2.0\",\n \"typescript\": \"^5.0.0\",\n \"wait-port\": \"^1.0.0\"\n }\n }\n\nServing static files\n--------------------\n\nWhen you generate or copy files during the custom build step, App Engine does\nnot serve these static files directly from your app using either the\n[`static_dir`](/appengine/docs/standard/reference/app-yaml#handlers_static_dir)\nor [`static_files`](/appengine/docs/standard/reference/app-yaml#handlers_static_files)\nelements defined in the `app.yaml` file. Instead, App Engine uploads\nthe static files to the serving infrastructure in the standard environment\nbefore running the custom build step. Any request to the files generated or\ncopied during the custom build step results in a `404 NOT FOUND`\nHTTP error."]]