Can I run git clone via an NPX tool - javascript

Im in the process of building a custom NPX tool which will add my custom npm package into a local hosted server,
I have as of right now a template of the structure id like to replicate when other users run my NPX command, something along the lines of
src
index.js
build
built_js.js
styles
styles.css
I understand when it comes to npm packages ill have to run these commands separately which is fine but im wondering how i can rebuild this directory on command npx create-my-app

yes you can!
try to use this package for it:
https://www.npmjs.com/package/create-clone

Related

Issues with deploying React based app on Railway

I was moving my fullstack app (React + Express) from Heroku.
The problem was that React app has to be built for running (also has to install required dependencies), but on git we usually store only raw source code.
A common structure for fullstack projects:
Heroku has the option to run scripts after deployment with a special script in the package.json file:
"heroku-postbuild": "npm install --prefix client && npm run build --prefix client"
But I didn't find a similar ability on Railway.
So my solution is:
Remove the build folder from the .gitignore file
Build react app with npm run build
Add all to git repository
Deploy on Railway via Git Repo
Do not forget to add environment variables
Create domain name to have access via public internet
Be happy!
I had some problems with this, so I am sharing the easiest solution for others.
By selecting a project on Railway, and going to its settings, you would find a field named Build Command. There you can add your build commands. For example, in your specific case, this should work:
cd client && npm install && npm run build && cd .. && npm i
If it does not work, look at your project structure and adapt the command. Currently, the field is there:
Go to the project setting and set your build command. I've fixed it this way- https://prnt.sc/OnYPp1Q5-Uze
npm run build

Cypress - install it on empty project

I am trying to install cypress on an empty project. However, cypress is not installed in the package.js file and cypress is not included on the project. How can I make it work? I cannot install cypress as part of the development project, so i am trying to create a separate test automation project with cypress.
Steps to install cypress:
Step 1: Create your project folder, go inside the folder from the terminal using cd folder_path/folder_name and run npm init. This will create your package.json file inside your project folder. You can do this in a sperate project or create some folder in your development project and do it there as well.
Step 2: Now, Run the command npm install cypress --save-dev. This will add the cypress as a dev dependency inside your package.json file. Once you have successfully installed this, you should see one more file package-lock.json and an folder node_modules being created
Step 3: Run the command node_modules/.bin/cypress open or node_modules/.bin/cypress run to run cypress.
You need to add --save or --save-dev to save it to package.json file. eg: npm install cypress --save. https://docs.npmjs.com/cli/v6/commands/npm-install
Normally you install Cypress into your dev project, but I see you can't do that.
Go to https://www.cypress.io, middle of the page is Download now.
After downloading, unzip to a folder, open bash or cmd prompt in that folder and type Cypress.
You get some warnings about installing into your project being preferred, but it works fine.
There's a To get started... box on the runner. Choose the same folder, and Cypress will set up the testing folder structure
/cypress
/integration
/examples -- lots of sample tests here
/support
/plugins
/fixtures
etc

How to create react app without git (skipping git)?

I don't want git initialized in my folder when I create react app by
npx create-react-app appName
When I was working with Angular, it was comparatively easier by just typing the command
ng new my-app --skip-git
Can anyone please tell me the related command for React? I tried searching but couldn't find any satisfactory answer.
There's an open GitHub issue for your case.
TL;DR: There are no current plans to include such an option. The React developers recommend you run rm -rf .git after npx create-react-app appName to achieve these results.
I had case where I have nodejs folder and I wanted to create react frontend project folder inside react project folder. I did it using this command npx create-react-app projectname --skip-git
Try npx create-react-app --skip-git.
If this is not working delete the .git folder manually .

'vue' is not recognized as an internal or external command

everything was installed correctly. but whenever I try to create project, it says "'vue' is not recognized as an internal or external command". I installed and re-installed but didn't work. npm was also added to environmental variable path.
C:\Users\touha\Desktop>npm list -g --depth=0
C:\Users\touha\.npm-packages
`-- #vue/cli#3.8.2
C:\Users\touha\Desktop>vue ui
'vue' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\touha\Desktop>
Locate vue.cmd and add its location to your PATH
It is added to package manager(npm or yarn) installation. So you may find it at following locations
YARN
C:\Users{YourAccount}\AppData\Local\Yarn\bin
NPM
C:\Users{YourAccount}\AppData\Roaming\npm
just open PowerShell and run: npm install -g #vue/cli
Addition: If setting the path variable and reinstalling #vue/cli does not work, using the node.js command prompt instead might solve the issue.
It seems vue isn't been installed globally for some reasons.
This is the step I followed to solve mine:
Firstly, create your desired project folder (say "Vue Project"). This is where you want to create a vue project.
Then create a "node_modules" folder in the Vue Project folder
Then go to your system npm folder C:\Users{YourAccount}\AppData\Roaming\npm
You will see three different "vue" files. Copy them and paste in the Vue Project Folder you created.
Go back to C:\Users{YourAccount}\AppData\Roaming\npm and enter the node_modules folder. You'll see a "#vue" folder. Copy this, and paste it in the node_modules folder you created in the Vue Project Folder.
You can now head back to the CLI and create your project using "vue create my-vue-project" where my-vue-project is your desired vue project name.
You can try this way it worked for me
go to the location of your yarn or npm mine is C:\Users\TED\AppData\Local\Yarn\bin for Yarn
C:\Users\TED\AppData\Local\Npm\bin for Npm users
TED will be replaced by your user name
then copy and add it to your system environment variable
Note in case you don't find AppData make sure you have view hidden file checked
I am using Yarn to install #vue/cli.
The way I solve it is via the following steps
Locate your global installed vue.cmd location
Add the vue.cmd directory into System variable Env. For myself, the path is C:\Users{MyAccount}\AppData\Local\Yarn\.bin
what worked for me:
In a powershell :
npm install vue
npm install -g #vue/cli
C:\Users\{USER}\AppData\Roaming\npm\vue.cmd create {NAME}
if you got this error most probably chance package not installed completely
check-in C:\Users\dev\AppData\Roaming\npm
if you had not found the package under this folder then re-run your command
Run command prompt as administrator
Run setx /M path "%path%;%appdata%\npm
Restart the command prompt
Now create the Vue project

How to install Node.js or npm on Xampp

I'm new, so please excuse any mistakes.
I am trying to develop a web application locally using XAMPP. I intend to deploy using a hosted web service. XAMPP was a very convenient way to get me up and programming without any fuss.
There are several github javascript libraries that look like they can only be installed with npm. Does this mean that I cannot use them? The specific one that I'm currently having a problem with is: https://github.com/selz/plyr. Or, is it possible to install npm on my XAMPP server? I have a windows machine.
Thank you very much in advance for your help.
is it possible to install npm on my XAMPP server
You will not be installing NPM on your server, you will be installing it on your machine (think of it as a regular program you install on your PC) (if your server happens to be your PC as well, then, well, you are technically installing it on your server)
In order to be able to use NPM though, since NPM is written in JavaScript, you will need to install Node.js, also on your machine.
So, head over to the Node.js site and download and install Node. NPM is included in the installer and will be installed alongside Node.
After that is done, installing NPM packages is simply a matter of heading to your desired directory and executing npm install <PACKAGE_NAME> there.
In general, XAMPP helps you with your back end. Not your front end.
Useful links:
https://docs.npmjs.com/
Does this mean that I cannot use them?
No. You can install node at https://nodejs.org and then use npm through your windows command line to install packages. To test this, just
Install NodeJS
Open Command Line
Make a new folder under your user folder called test mkdir test
cd into that folder on Windows Command Line cd test
Create a new project with npm init -y *note this creates a
package.json file for you
Now you start installing packages with npm install <package>
--save * --save saves the package info in your package.json file (recommended). There is also -g wihch means the package will
be installed globally (usually you don't want this and only want it
locally to your project).
That's how you use NodeJS. If you want to use that with XAMPP then you need to do the same thing but instead of using your user folder (C:\users\yourname) you need to use the htdocs folder of XAMPP (usually C:\xampp\htdocs)

Categories

Resources