Using the schematics commands in Spartacus - spartacus-storefront

I am trying to use the schematics command "npx ng #spartacus/schematics:add-pwa" (I am not using a global npm repo or angular installation, due to version conflicts with other projects).
I get the following output:
The specified command ("#spartacus/schematics:add-pwa") is invalid. For a list of available options,
run "ng help".
Did you mean "analytics"?
ng cli commands work fine, also adding #spartacus/schematics worked fine (npx ng add #spartacus/schematics#latest), yarn build works fine (npx yarn build).
If I run npx ng add #spartacus/schematics --ssr, this also works fine, prompts me again for the features I want and adds SSR to the project.
Do I have to do anything else to be able to run the additional Spartacus Schematics commands as they are mentioned in the documentation (https://sap.github.io/spartacus-docs/schematics/#additional-commands-for-core-libraries-and-features)?
Thank you!
Cristi C.

Did you try to run npx ng add #spartacus/schematics --pwa?

I found the answer to my question. It was a mistake on my side. I was trying to call:
npx ng #spartacus/schematics:add-pwa
but the correct call is:
npx ng g #spartacus/schematics:add-pwa
Reading the documentation with more attention helps...

Related

What is the equivalent of npm run start:ci in yarn?

I'm trying to configure Bitbucket CI/CD for cypress testing on my vue app which uses yarn for package management.
Is there any way to start server in background by yarn?
Thanks in advance
Welcome to stackoverflow Alessandra.
yarn start command is equivalent to npm run start
However if you have created a custom command in your package.json for start:ci you can use equivalent yarn command as yarn start:ci
You can also use yarn run start:ci however its run is redundent here. Please see this documentation
https://classic.yarnpkg.com/lang/en/docs/cli/run/

Is there any Yarn equivalent of npx preact create?

I am trying to run the preact create command using Yarn. It's simple to run preact create ..... ..... or npx preact create ... ..... It works fine and both of the commands use npm. But I am trying to run the command using Yarn. I have tried the following commands but nothing works. The error says "couldn't find a package.json file in path".
yarn preact create .... ....
yarn dlx preact create .... ....
yarn preact-cli create .... ....
yarn dlx preact-cli create .... ....
So, what should I do to run the command using Yarn. One alternative maybe is running the command using npm and then running yarn install and then running npm uninstall. But what's the actual way?
There is no Yarn equivalent for npx. The Yarn team thought npx was enough.
That being said, we support creating a new Preact CLI project with Yarn through the --yarn flag.
npx preact-cli create ... --yarn
https://github.com/preactjs/preact-cli#cli-options
Please do note that when using Preact CLI via NPX, you do need to use preact-cli. npx preact gives you the Preact library.
In general, as of 2021, there is no equivalent for npx
Feature was requested in yarn, but went not really solved
https://github.com/yarnpkg/yarn/issues/3937
So package developers need to think for both npm and yarn users.
You can use ynpx as an equivalent.
yarn global add ynpx
Then do your npx commands as normal, using ynpx in place of npx
eg.
ynpx preact create ...
For a TL;DR answer from the thread mentioned above.
You can find the following.
npx performs no operations which clash with people using other package managers [...] So you could say npx is ypx, unless you feel really strongly about cache-sharing, which is a pretty thing.
For the probable reasoning of not creating a ypx specific command
Yarn now supports create cli as following
yarn create [your-cli-name] [..arugments]
for eg. yarn create expo-app hello-world

How do I correctly scaffold a new Docusaurus website?

Trying to get started with a Docusaurus v2 website. Don't know much about npm or JavaScript in general, so maybe I'm missing something obvious.
I'm on Ubuntu 20.10, npm -v is 6.14.8, npx -vis 10.2.2 and yarn -v is 1.22.5.
When I execute the example from the documentation, I get an error:
$ npx #docusaurus/init init my-website classic
Too many arguments.
If I try without the name or template, I would expect it to prompt for them, but get another error:
$ npx #docusaurus/init init
Expected single character argument.
Is there something fundamentally wrong with my npm installation?
Thanks
Turns out, I just had to user a newer node version. Details about the issue are here.
A workaround would be to use #latest as in
npx #docusaurus/init#latest init my-website classic

"--watch is not supported without git/hg" with cygwin jest and git

I would really appreciate help with this.
I have cygwin installed and set up to use the PATH from windows. This has been working great for a ton of node development, but I've recently run into an issue where when I run
yarn jest --watch
I get the following error:
--watch is not supported without git/hg, please use --watchAll
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I have installed git and node in windows.
I have found a workaround of using the Command Prompt for running the tests, but would really like to be in one environment.
--watch works only for git repositories.
if you still have issue it is yarn issue npm gives the same error too. delete your node_modules folder, update yarn or npm to the latest version, then reinstall all the packages again.
After some consideration, I thought my workaround could be a valid answer to this question. Although, I would still like to get this working properly in Cygwin.
If you have node and git installed in windows then you can go into the Command Prompt and run yarn test --watch or npm run test -- --watch to accomplish the same thing.
I know it's been a long time. But i was facing the same issue and what resolved it for me was, to change the default terminal of whatever editor you're using to GIT command line. I was using VS Code and changing the terminal to GIT worked like a charm.
Make sure you're running it in a Git repo (initialised with git init). Otherwise it doesn't know how to get only the changed files.
If you don't want to run tests only on changed files, you can use --watchAll, which runs all the tests.
I also encountered this problem, the reason is that I use the mv command to move the project folder, however the command was not removed .git has points such as the beginning of the file
npm run test -- watchAll
Please use watchAll to serve it in a continue way. It will track your changes and re-run the test automatically.
git init
solves the problem, that way it knows the changed files

Error while running the existing React Native project

So I'm opening my the existing React Native project. This is the procedure on how I opened my existing React Native project. 1st step, type the location of my project which is in the "D:\rnprojects\firstproject\". 2nd step, "react-native-start". 3rd step, I opened another cmd then locate it again into my project directory then typed "npm start".
Why when I created this project I didn't get this error just when runnning/opening my existing project.
This the error that I got: (with versions)
There is only simple steps can solve your particular scenario issue quickly.
1) Install the React native cli in your project or globally.
npm install -g react-native-cli
OR
npm install react-native --save
then start your project by using this command
npm start
If any dependencies issue please follow the second solution
2) Please make sure you're installed all dependence
yarn install
OR
npm install
under your project directory
I'm pretty sure your issue will fix by using 1st solution Thanks.
it is simple:
1.npm install
2.react-native run-android
Here I guess you have the RN environment to run already on your side.
cd path_to_project
install packages(there are two following ways to install packages).
2.1 yarn install
2.2 npm install
react-native link(optional - you need to run this command if existing project use RN packages which need to link such as
react-native-vector-icons)
optional(if project use pods) cd ios pod install
react-native run-ios or react-native run-android according to the platform which you want to run on.
I don't think above is perfect instruction give you how to run the existing react-native project, But I am pleasure if give me some hints or help to you.
You can find official guide here
Sometimes npm's cache gets confused and need to reset it by using below command:
npm cache clean --force
Also try below command:
npm install --save-dev react-native-cli
Hope it will help you.