How can I deploy an app using legacy peer deps? - google-app-engine

So I have two packages in my project with conflicting peer dependency. One of the deps is only supporting react^16.14.0.
So I managed to get it to work locally by using npm install --legacy-peer-deps, but how can I use this command when I deploy my project to Google Cloud App Engine? App Engine install fails with Could not resolve dependency.

For me, I got this working by creating .npmrc in the root of my project. And adding legacy-peer-deps=true in the file. Source

So, the reply from #keyur Shah worked for me.
Except I did only enter legacy-peer-deps in the .npmrc file located in the root of the project. ( instead of legacy-peer-deps=true )
the link he mentions ias source is: https://issuetracker.google.com/issues/241076152

Related

How to do app versioning in create react app?

I need to display version of my react app in the footer in x.y.z format.
I need this version to increment every time I deploy the app by being provided a choice if I want to increment x or y or z.
How do I achieve this? :)
To bump the version of your app you can use npm version.
For example:
npm version minor
Once you have a way to bump the version in package.json (e.g. npm version, as suggested by #bertrand-p), you can then assign the version to an environment variable. For example, in .env you can set:
REACT_APP_VERSION=$npm_package_version
Then you can access the variable from within your app via process.env.REACT_APP_VERSION.
See also: https://github.com/facebook/create-react-app/issues/2466#issuecomment-357490359
I don't think the answers from #Bertrand P or #VulfCompressor tell the complete picture. I used genversion https://www.npmjs.com/package/genversion. The steps I did were:
npm install genversion --save-dev
Modify the build script in package.json to genversion --es6 src/autobuild_version.js && react-scripts build (I couldn't figure out a way to import the generated module from the lib directory as suggested in the genversion documentation so I had to put it in the src directory instead)
In the React app, import { version } from './autobuild_version' and use as appropriate
Add src/autobuild_version.js to .gitignore (other source code control tools are available)
npm run build
You can use grunt-bump to handle your app versioning. As for displaying your app version, refer to Is there a way to get version from package.json in nodejs code?.
You can use npm commands below in different conditions mentioned below and the commands will effect the version number in package.json in your react project.
You can access that version by installing dotenv by npm i dotenv oryarn add dotenv and use the .env file in your root folder and access the version number in the whole app with REACT_APP_VERSION=$npm_package_version. You can find more commands at npm version documentary page. commands below will add to version numbers like this: "version":"{major}.{minor}.{patch}"
If its a major change(bug fixing) in your app use:
npm version major
If its a minor change(bug fixing) in your app use:
npm version minor
And if it's just a patch upgrade such as changing some styles use:
npm version patch
You can use versioning for many purposes and one of them is for making sure client's cache will be renew and they would have the updated content.

How do I install my forked React modules into Symfony 4?

I'm trying install a React module into my Symfony 4 project. I already have the React entry point setup and running with webpack encore, and now I want to add a module to the React app.
The React module has a github and can be installed through npm, but how do I install it into Symfony? How do I deal with the webpack.config.js and package.json files in the package, since Symfony has its own for these files.
I have compared the webpack.config.js and it seems like the Symfony one can override the other one, since it already covers React entry point and babel setup. What do I do?
Another problem I have is that the original module was outdated, so I forked the project to my repository, updated it and filed a pull request. But since the PR is still pending, I wanted to install my fork for now, what do I need to do?
NPM supports installing dependencies directly from github (or other git host) https://docs.npmjs.com/cli/install so executing npm install github:<githubname>/<githubrepo>[#<commit-ish>] should work fine from the package.json directory.
The React module has a github and can be installed through npm, but how do I install it into Symfony? How do I deal with the webpack.config.js and package.json files in the package, since Symfony has its own for these files.
I'm not familiar with Symfony, does it manage your NPM dependencies after install? If so you will have to determine how to accomplish the npm install via Symfony.
Another problem I have is that the original module was outdated, so I forked the project to my repository, updated it and filed a pull request. But since the PR is still pending, I wanted to install my fork for now, what do I need to do?
As per above, just specify your git path until your PR is pulled, then update package.json to the original repo

React Native "The expo SDK requires Expo to run. .... this code is not running on Expo."

I am coding with React Native. I don't see that when I first create react-native app for check running. When I implements my code see that. My purpose is generate apk.
app.json
build.gradle
index.js (index.android.json)
App package.json
Solved
Result: I solved my problem with npm install. I would like say many month after.
If anyone's getting this error after upgrading Expo, try restarting your simulator - that fixed it for me.
Here is my experience if someone using expo sees those error message.
I accidentally installed expo manually in my project which was version 29.0.0.
I was using version 28.0.0 of expo sdk, so it may have crashed inside.
What I did:
manually upgrade sdkVersion of app.json to 29.0.0.
change sdk version to 29.0.0 for react-native.
Had exactly the same error - fresh machine, fresh npm, only one version of expo installed.
Turns out, expo requires you to build it as an app before it can send it to the expo app properly (at least on Android). This is easiest done by:
Adding an "android" section to app.json, with the contents "package": "uk.co.yourcompany.yourpackagename" (this is required by android packages. It can be complete garbage, but should follow that format - a backwards domain name)
running expo build:android and following the instructions to sign up to expo's servers and build the app
then restarting expo start
Not sure if this is documented anywhere though, so may be a new thing?
Another thing to try is to move your node_modules folder away (or maybe delete it, up to you) and re-run npm install
According to the official tutorial: https://facebook.github.io/react-native/blog/2017/03/13/introducing-create-react-native-app.html
If you want to use expo in your application, you must create it in the following way
npm i -g create-react-native-app
create-react-native-app my-project
cd my-project
npm start
This will start the React Native packager and print a QR code. Open it in the Expo app to load your JavaScript.
as I see your code has files that are not necessary, such as build.gradle and index.js, the structure that create-react-native-app creates is different and easier to use
I was getting the same error after updating the expo-cli to version 3.0.6.
By looking at my package.json I noticed the expo-cli version installed on my computer is not the same as package.json. so I changed it to "expo-cli": "^3.0.6" and ran npm install || yarn, then the error disappeared!

How to deploy MEAN Stack to web host

I have a node API and an angular front end project (via grunt, bower, yeoman flow structure) as two separate github repositories. I am trying to push them both to production through Heroku. Coming from a rails bg where everything in the app exists in the same project directory, and you only have to push one directory, how would you do this? Should I push both projects as separate heroku projects or is there a best practice out there? I'd appreciate any and all advice, thank you in advance.
Firstly, I would review the official Heroku doc on deploying nodejs apps
If you have two projects, you will probably want to deploy them as different heroku apps.
The key here is going to be making sure your package.json is set up correctly. Make sure all your dependencies are correct and present, and your package.json points to your node server script. Make sure you have your dev dependencies like grunt separate from your production dependencies also, as these don't need to be deployed to production. If this is just a demo app, you can have heroku install all your scripts (like angular) simply by including them in your package.json. When you push your app, it will run an npm install on your package.json and install it the dependencies.
There are a few ways you can deploy also - via the heroku cli, a github link, or a dropbox link. I haven't personally used the cli much, but I have found the other two convenient to use, especially if you are already pushing to github.
One key thing too is that if you need to install dependencies with bower, you should know that heroku DOES NOT run bower install on it's own. You can tell heroku to run it by adding the following to your package.json:
"scripts": {
"postinstall": "bower install"
}
This will cause it to run a bower install after npm install finishes.
Also, if you haven't done so already, you'll need to set up your database somewhere with a 3rd party provider (like mongolab or modulus).

How can I run my bower-angular project?

Hi everyone I know its simple question but I am new the angular development.
I have angular projects but I cant run.
I know npm using on console, I tried many times npm run, npm instal on my main directory.
So, how can I run my angular project on the console?
If the project is using Angular Seed or is similarly configured, you can use
npm start
to install dependencies and start a running http-server on port 8080 (by default).
If you project has a README or package.json file, it might give more clues.
Otherwise you can just serve up the application with http-server:
npm install http-server
http-server .
Asume you are using NodeJS as a server side, try node [your-application-main-js-file.js]. For example node index.js. But it depends on what back end environment are you using. Angular is just a front end library/ framework. It should be tested on browser not in your console.

Resources