Closed stemixreal closed 3 years ago
Same issue for me as well.
I'm finding my way with this but adding
- uses: actions/setup-node@v2 with: node-version: 14
produces
Run actions/setup-node@v2 with: node-version: 14 always-auth: false check-latest: false token: * Found in cache @ /opt/hostedtoolcache/node/14.15.4/x64**
Adding
_- run: npm install
fails with the error that package.json doesn't exist in the root of the app as indicated in a roundabout way in the original second error.
I've installed the node modules in /api and package.json was created there automatically. Do I need a copy in the root too/in place of? I've have tried that but no luck. Same error. So I'm missing something obviously.
Should my build process even be trying to install Node? It doesn't appear so. This began after I added Cosmos DB for Azure tables Javascript libraries.
Ok I think I've sorted this out. At least, everything builds though there were a couple of errors during the build they don't break the build - missing descriptions and the like.
@monksudo, there were superfluous package files in my root (an oversight on my part). Once I deleted those the app deploys ok. I deleted both package.json & package-lock.json which caused the build process to try to install node in the root which is unwanted and impossible anyway it seems.
@stemixreal If you can share a repo that reproduces the original problem, happy to take a look to see if there's anything we can do to make this experience better.
Hi Anthony, thanks. The error was mine. I mistakenly installed all the node packages in the web root initially and neglected to deleted the node_modules folder from there. I didn't notice it among other files and folders to be honest. So even though I then installed things correctly, the build was trying to install node in the SWA root.
The repo is private but happy to send an invite. It's just a static web app with some signalr hub and cosmos db tests for a game I'm working on.
I guess I must have broken something when fiddling about though. I'm getting internal server errors from the function that was working. No worries though. It's no problem to take a couple of steps back.
same issue facing
Same error. Deleting package-lock.json fixed it. Thank you !
If this is still an issue for some developers. You may be facing at one of the following issues:
Duplicate package.json or yarn.lock or any similar file in the upper directory and the project directory. In such a case delete any of the packages as jrathgeber did above. Be careful here, open and see which one is not required.
Old npm directory. One of the issues could be that one of your pages is missing from the script. It may work locally because you had installed the package earlier. Check that they are all installed. Try deleting the node_modules folder and reinstalling the packages. If it works locally, then it should work in the cloud as well.
Difference in node versions. Make sure the app you aim has a similar environment as your local machine. Add the following or similar to your package.json "engines": { "node": ">=18.0.0" }
Wrong directory. Make sure you get your publish and src directories right. For example, React would require something like this in the workflow file :
app_location: "/name_of_project"
output_location: "build"
Custom build. If this is your case, then add your commands in package.json under scripts. For example, "mycustomscript": "yarn install && yarn build"
, then call this as an app_build_command: 'yarn mycustomscript'. Read more about this here.
Hi Folks,
I have a static web app and have recently added additional functions to /api to enable me to use cosmos db. After adding and testing the functionality locally I deployed the changes.
The deployment failed with the following Oryx errors
Detecting platforms... Detected following platforms: nodejs: 14.15.1 Version '14.15.1' of platform 'nodejs' is not installed. Generating script to install it...
Error: Could not find either 'build' or 'build:azure' node under 'scripts' in package.json. Could not find value for custom run build command using the environment variable key 'RUN_BUILD_COMMAND'.Could not find tools for building monorepos, no 'lerna.json' or 'lage.config.js' files found.
---End of Oryx build logs
Oryx could not find a 'build' or 'build:azure' script in the package configuration. Please add one of these commands to your package configuration file (i.e. package.json). Alternatively, you can add the app_build_command to the build/deploy configuration section of your workflow file. For example, app_build_command: 'npm run docs:build'
...
I've had a look around and found:
https://github.com/microsoft/Oryx/issues/891
but as everything has worked without issue in deployment so far I haven't really looked into Oryx/Actions in any great detail so I don't know if the fix is something I can use for static web apps. Where would I apply the suggested workaround if it is possible? I can't see anything in the workflow yaml that gives me any clues. The solution is for an app service hosted function.
https://github.com/microsoft/Oryx/issues/891#issuecomment-756147542
Any pointers greatly appreciated. Cheers Steve