我试图在 Netlify 上设置持续部署。我已经链接了我的 Github 帐户,所以我现在需要设置我的构建命令:
复杂之处在于我的带有构建命令(来自 create-react-app)的 package.json 不在项目根目录中。相反,它的 1 个文件夹如下所示:
react // this is a folder
-package.json // has build commands for React
server // this is a folder
-package.json // has build commands for my backend as a service
当我使用后端作为服务时,我不需要部署到 Netlify 的“服务器”文件夹中的任何内容,只需要“反应”文件夹的内容。
我可以从项目根目录运行 react/package.json 中的命令吗?
在我的本地机器上,我可以使用以下命令从根目录运行构建命令:
{
"scripts": {
"netlify": "cd ./react && npm run build"
}
}
但在 Netlify 上出现错误:
9:56:31 AM: Executing user command: npm run netlify
9:56:31 AM: > @ netlify /opt/build/repo
9:56:31 AM: > cd ./react && npm run build
9:56:32 AM: > testproject@0.0.1 build /opt/build/repo/react
9:56:32 AM: > npm-run-all build-css build-js
9:56:32 AM: sh: 1: npm-run-all: not found
9:56:32 AM: npm ERR! file sh
9:56:32 AM: npm ERR! code ELIFECYCLE
9:56:32 AM: npm ERR! errno ENOENT
9:56:32 AM: npm ERR! syscall spawn
9:56:32 AM: npm ERR! testproject@0.0.1 build: `npm-run-all build-css build-js`
9:56:32 AM: npm ERR! spawn ENOENT
9:56:32 AM: npm ERR!
9:56:32 AM: npm ERR! Failed at the testproject@0.0.1 build script.
9:56:32 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
9:56:32 AM: npm WARN Local package.json exists, but node_modules missing, did you mean to install?
9:56:32 AM: npm ERR! A complete log of this run can be found in:
9:56:32 AM: npm ERR! /opt/buildhome/.npm/_logs/2018-03-01T02_56_32_022Z-debug.log
9:56:32 AM: npm ERR! code ELIFECYCLE
9:56:32 AM: npm ERR! errno 1
9:56:32 AM: npm ERR! @ netlify: `cd ./react && npm run build`
9:56:32 AM: npm ERR! Exit status 1