`/bin/sh: 1: tsc: not found` in Gatsby Cloud - reactjs

I get /bin/sh: 1: tsc: not found error on build in Gatsby Cloud.
How can I fix this to build successfully?
I believe the reason for this would be I am specifying a branch for a npm package.
The npm package doesn't provide features I need and I cannot wait for PR to be merged, so I forked and modified the package with specifying it in package.json like:
{
"dependencies": {
"some-package": "https://github.com/xxxx/some-package.git#temporary"
}
}
It works fine on local development but not when building in Gatsby cloud.
Is there any way to fix this?
I tried to use gatsby-plugin-typescript(link) but didn't work.

Related

Android build failures happening since 4th Nov 2022[FIX INSIDE]

The build error looks something like this:
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'My Project'.
Could not determine the dependencies of null.
Could not resolve all task dependencies for configuration ':classpath'.
Could not resolve com.facebook.react:react-native:+.
Required by:
project :
No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.
The consumer was configured to find a runtime of a library compatible with Java 11,
packaged as a jar, and its dependencies declared externally, as well
as attribute 'org.gradle.plugin.api-version' with value '7.3.3'
update this below content in project level build.gradle:
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// ...
}
}
it's working for me
FIX INSIDE
Steps to resolve the react-native issue that we are facing since couple of days.
Goto package.json and upgrade the react-native version to 0.64.4.(or whatever the supported version we have on the GitHub thread)
Run yarn install.
Now cd android
./gradlew clean
cd ..
yarn android (now your project will execute properly)
Note: This issue occurred because of the new release of the react native(4th nov), here I'm attaching the link for the reference.
URL : https://github.com/facebook/react-native/issues/35210
(if you face any issues do let me know i'll help you in resolving the same.)
This fix works:
Reason for Failures : The build failures for Android was due to the publish of the React Native version 0.71.0-rc0 to Maven and because of which when the gradle is syncing its picking this 0.71.0-rc0 version of react-native rather then your current version of react-native.
Made it work without upgrading react-native version and by adding this in build.gradle, this works (hermes enabled or not, along with flipper too)
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
final snippet looks like this
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
gradle clean and rebuild after this fix. Then you can react native run android successfully.
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
If you dont want to put this fix, you can update your react native version for the project to the react native patch version as mentioned here
https://github.com/facebook/react-native/issues/35210

Azure pipeline "npm install" but package doesn't exist anymore

When building my project in Azure pipeline, there is a step that does npm install.
However one of the package it requires doesn't seem to exist anymore on NPM. What are my options now?
8412 error code E404
8413 error 404 Not Found - GET https://registry.npmjs.org/angular-appinsights/-/angular-appinsights-0.0.4.tgz
8414 error 404
8415 error 404 'angular-appinsights#0.0.4' is not in the npm registry.
8416 error 404 You should bug the author to publish it (or use the name yourself!)
Edit I have added this package privately to Azure Artifact feed, and all other NPM packages (not privately) as well, would this mean that if in the future someone removes there package from NPM I would still have the (artifact feed) as backup?
Caution: this might not be the best practice
I had a similar issue with some legacy app that was built upon the beta of Material UI. When putting the application on a CI/CD pipeline what we had to do was before launching npm install have a script move the node_modules folder to where the application was being built and then launch npm run build because in this case it was a React App (I'm guessing it is similar for Angular).
What I would suggest is that you have a copy of that package from the node_modules folder copied into a node_modules folder while deploying before running npm install because npm won't install packages it finds are already there.
Of course best practice would be to update that package but I'm guessing that is not up to you. If you could, I would suggest you ask the developers to review the dependencies or to tell you how they deploy that application locally because, from the little research I've done it seems to me that there other up-to-date packages available. They might have installed the newest package but forgotten to remove the old one and since they have never had to redeploy simply didn't stumble upon that error, other possibility is they're passing the node_modules folder around.

getting error when run npm start command with gatsby

When I run command npm start it's giving me error
ERROR
gatsby develop
Start development server. Watches files, rebuilds, and hot reloads if
something changes
And when I run command gatsby build it's giving me this error:
gatsby can only be run for a gatsby site. Either the current
working directory does not contain a valid package.json or 'gatsby' is
not specified as a dependency
I tried to delete node_modules and install again but still giving me the same error. How can I fix this?
It seems that you are not running the commands in the proper folder.
npm start, gatsby develop or gatsby build must be triggered in the root of your Gatsby project, where the package.json is located.
Share more details about where and how are you trying to run npm start and even your project structure in order to know what's going on.

Expo EAS not resolving sentry-expo. Are dependencies cached?

I've joined the EAS preview, and I'm having problem when building my app. The build works perfectly with the classic build system. Here is a screenshot of the problem:
I think that EAS is caching the dependencies, but I'm not sure if this is the problem or how to clear their cache.
The first time I built the app, the process was slighty different:
As you can see, there is a "Install dependencies" step that isn't in the newer builds. That error of the install dependencies is already fixed.
I've sentry-expo in my package.json and in my app.config.js I have plugins: ["sentry-expo"],
I've also tried adding "cache": {"disabled": true} to the android build config with no success.
Does anyone know how to fix this problem?
Thanks!
This is likely a dependency management issue. In my case I was attempting to use yarn "pnp" which which doesn't support react-native at this time to my knowledge. I reverted that and was able to get past this.
My .gitignore
# yarn berry
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
My .yarnrc.yml
yarnPath: '.yarn/releases/yarn-berry.cjs'
nodeLinker: 'node-modules'
Try to install dependencies
npm i sentry-expo -s
yarn add sentry-expo
And rebuild eas build --platform ios --profile preview
This is working for me

Installing Gatsby plugins breaks entire app

Whenever I install any gatsby plugins or typography files, and then attempt to run gatsby develop, I am thrown an error sying that 'react' can't be found. Example:
I create a new gatsby site using gatsby new example-site https://github.com/gatsbyjs/gatsby-starter-hello-world
I install the gatsby-plugin-sass using npm install --save node-sass gatsby-plugin-sass
I follow the instructions on the plugin page, adding the plugin to my gatsby-config.js file.
When I now attempt to run gatsby develop I receive the following errors:
ERROR
There was a problem loading the local develop command. Gatsby may not be installed. Perhaps you need to run "npm install"? Cannot find module 'react'
Error: Cannot find module 'react'
As well as a list of files that the errors are being thrown in, most of them in internal files.
Clearly I have the Gatsby-cli installed, as well as react. I'm also receiving a ton of warnings about deprecated related to core-js and optional dependencies not being installed.
In my research, I have found people saying that using yarn instead of npm solves the issue, but with Gatsby being as large of a project as it is, and with the documentation itself saying to use npm, that doesn't seem like a solution but rather a work around. Is there any other info on this that I just can't seem to find?
I reprodued your error, and after looking around I found several issues on the Gatsby GitHub repo with the same behavior.
It seems that this is a problem with npm itself, which is why the community is increasingly switching to yarn.
If you'd like to stick with npm, the solution is to clear your node_modules and package-lock.json, then reinstall your dependencies (source):
rm -rf node_modules/ package-lock.json
npm install

Resources