gpt4 book ai didi

node.js - npm 错误!缺少脚本 : build:universal

转载 作者:行者123 更新时间:2023-12-04 16:26:43 37 4
gpt4 key购买 nike

我正在尝试在服务器端运行我的 Angular 应用程序,但我遇到了以下错误:

npm ERR! missing script: build:universal

npm ERR! A complete log of this run can be found in: npm ERR!
/home/training/.npm/_logs/2018-10-03T11_50_40_593Z-debug.log



我使用官方的 Angular 应用程序来做这件事

https://angular.io/guide/universal

通用构建导致如下所示的错误:

0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/nodejs', 1 verbose cli '/usr/local/bin/npm', 1 verbose cli 'run', 1 verbose cli 'build:universal' ] 2 info using npm@6.2.0 3 info using node@v10.8.0 4 verbose stack Error: missing script: build:universal 4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:155:19) 4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:63:5 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:115:5 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:418:5 4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:373:45) 4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:416:3) 4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:160:5) 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:280:12 4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16 4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3) 5 verbose cwd /home/training/Desktop/vishnu/TemplateAppv6 6 verbose Linux 4.4.0-134-generic 7 verbose argv "/usr/bin/nodejs" "/usr/local/bin/npm" "run" "build:universal" 8 verbose node v10.8.0 9 verbose npm v6.2.0 10 error missing script: build:universal 11 verbose exit [ 1, true ]

最佳答案

正如我在评论中暗示的那样,您可能忘记将构建脚本添加到您的项目中:

来自 universal docs

Build and run with universal: Now that you've created the TypeScript and Webpack config files and configured the Angular CLI, you can build and run the Universal application.

First add the build and serve commands to the scripts section of the package.json:


"scripts": {
...
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:ssr": "node dist/server",
"build:client-and-server-bundles": "ng build --prod && ng run angular.io-example:server",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"
...
}

所以检查你 package.json 并再次尝试构建..

关于node.js - npm 错误!缺少脚本 : build:universal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52626669/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com