I am building a ReactJS library component. The demo app that uses this component is located within the demo directory (location: js/react/demo). The app that I am trying to deploy is this demo app.
But this doesn’t work when I am deploying to netlify.
I tried other build commands as well such as:
rollup -c
rollup -c && cd demo && npm run start
npm-run-all --parallel build-watch start-demo
I have managed to deploy other apps on netlify in the past (but they all were simpler apps that would build by yarn build), but this one has a different structure and I don’t know how to proceed.
I presume I need to handle this deployment differently because it makes use of rollup?
Can you help me deploy this app? Thanks.
You may serve it with a static server: serve -s build
I do get my app working at both the provided URLs.
But when I try to replicate this on Netlify, it seems to fail (I am very likely not doing all that is needed).
I keep encountering this error in my logs:
10:07:16 AM: [1/4] Resolving packages…
10:07:16 AM: error Package “” refers to a non-existing file ‘“/opt/build/repo/js/react/node_modules/@material-ui/core”’
The @material-ui package is listed as peerDependency and I’m not familiar enough with your project to know what should be installing that.
To debug I’d suggest starting again from a fresh clone of your own repo and paying attention to the steps you need to perform to get it working locally. You’ll need to ensure that the instructions you provide Netlify perform those same steps.
I believe that by default Netlify only run an install in the Base directory so if you need to run multiple npm/yarn installs the rest would be the responsibility of your build command or scripts.
Thanks a lot @nathanmartin !
This was the best advice (on hindsight obvious, but it got me thinking along the right path):
To debug I’d suggest starting again from a fresh clone of your own repo and paying attention to the steps you need to perform to get it working locally. You’ll need to ensure that the instructions you provide Netlify perform those same steps.
For the benefit of any future users, describing what I did here:
git clone --single-branch --branch react_lib https://github.com/appukuttan-shailesh/neo-viewer
cd neo-viewer/js/react
npm update && npm run build-lib && npm run i-all && npm run build-demo
serve-s demo/build
This worked for me locally.
FYI, my “scripts” is set as follows:
"scripts": {
"build-lib": "rollup -c",
"build-lib-watch": "rollup -c -w",
"build-demo": "npm run build-lib && cd demo && react-scripts build",
"start-demo": "cd demo && npm run start",
"i-all": "npm i && cd demo && npm i",
"dev": "npm-run-all --parallel build-lib-watch start-demo"
}
So now I set the “build” command on netlify to: npm update && npm run build-lib && npm run i-all && npm run build-demo