How do you get parcel to open in a specific browser of my choice? - parceljs

My parcel bundler opens up in default MS edge but i want it open local host in firefox.

Both work on Win10 and Linux Ubuntu 20.04. If you have parcel installed globally
In your root project folder enter the command(terminal)
parcel --open firefox index.html
OR
If you have parcel installed locally than change your package.json
"scripts": {
"dev": "parcel --open firefox index.html",
"prod": "parcel build index.html"
},
And hit in terminal npm run dev
You are done ! :-) Good Luck and Best regards;-)

Related

How to deploy a budo/browserify project's build to GitHub Pages?

I want to deploy a clone of this Virtual Art Gallery project to GitHub Pages.
However, I'm only able to deploy the base html site rather than the build site which shows a 404 page on GitHub.
Steps I've taken:
Created a GitHub Pages site at USER.github.io and added the code below to the package.json:
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
In another run I created a new repo USER.github.io/REPO and added the code below to package.json:
"homepage": "https://USER.github.io/REPO",
...
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
I've installed gh-pages and ran npm start, npm run build, npm run deploy.
In some attemps, deploy returned Error: ENOENT: no such file or directory, stat 'directory/BUILD' but I fixed this by running npm start first.

Opening a new powershell/windows terminal while react app is running

Hi I made two react apps which should interact with each other(both start with npm start). And I want to ask if it is possible to make a script to run the start up commands like a script file on Linux. (It will be like cd.. npm start then start powershell(not sure about this) then cd ... npm sart)
Sorry if the question is vague
You are looking for "concurrently",
npm i concurrently --save-dev
And then change commands in the "package.json"
"scripts": {
"dev": "concurrently --kill-others \"cd backend && node server.js\" \"react-scripts start\""
},
Now, You can run all commands at once with this;
npm run dev

visual studio code not recognized parcel

hey guys i new to parcel and i am trying to use parcel to build my website on it. i installed parcel using
npm install --save-dev parcel
but didnt work. then i ran parcel index.html and it returns
parcel : The term 'parcel' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name,
or if a path was included, verify that the path is correct and try again.
i tried uninstalling parcel and reinstalling but didnt work. Any ideas why this happens? thank you in advance.
below is my package.json
package.json
{
"dependencies": {
"dat.gui": "^0.7.7",
"gsap": "^3.6.0",
"load-asset": "^1.2.0",
"nice-color-palettes": "^3.0.0",
"three": "^0.126.1",
"vec2": "^1.6.1"
},
"devDependencies": {
"glslify-bundle": "^5.1.1",
"glslify-deps": "^1.3.2",
"parcel": "^2.0.1",
"parcel-bundler": "^1.12.5"
}
}
When you run npm install --save-dev parcel, you are installing local packages that are only intended to be used in this particular project, not everywhere on your computer (see docs). So commands associated with those packages aren't added to your CLI's global path by default. One way to run locally installed commands is to put them your package.json's "scripts" field:
{
...
"scripts": {
"build": "parcel index.html"
}
}
When they are run in that context, they'll have access to the locally installed packages.
I noticed another problem with your package.json - you have both parcel-bundler and parcel packages installed. parcel-bundler is the deprecated v1 version of parcel, and when it's installed side-by-side with the parcel (v2) package, it will override the parcel command in your scripts, so you'll be getting v1 instead of v2, which is probably not what you want. I'd recommend running npm uninstall parcel-bundler.

VSCode does not detect any of my pytest tests

I am trying to get my unit tests to show up in VSCode's test explorer, but it does not seem to be working. The test discovery does not fail with any errors in the output, but also does not show any of my tests.
This is the repo I am working in, you can see the file structure there.
This may or may not have anything to do with me using poetry to manage my virtual environment, though I'm sure the python interpreter is set correctly. I can get my tests to run perfectly well manually by running pytest or poetry run pytest in my base directory. I do have an empty __init__.py in my tests directory. Also of note is that I'm running in Ubuntu on WSL 2.
I set this up environment with the following process:
Install WSL2 on Windows
Install VSCode on Windows
Install the 'Remote - WSL' VSCode extension
Open a new WSL Window in VSCode
Install Anaconda in Ubuntu using this guide
Install the VSCode Python extension
Set the VSCode python interpreter to the anaconda install, and open a new terminal
pip install poetry
Go to my project root folder
poetry install
Set the VSCode python interpreter to the poetry environment, and open a new terminal
Done, I can run pytest via the command line
Here's my workspace setting.json:
{
"restructuredtext.confPath": "${workspaceFolder}/docs/source",
"python.testing.pytestEnabled": true,
}
Here's what the output shows when I try to refresh tests:
~/.cache/pypoetry/virtualenvs/monaco-bfS1OgpY-py3.9/bin/python ~/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/coding/monaco -s --cache-clear
cwd: ~/coding/monaco
If I run the above command manually in the terminal, it prints out a large dict which looks like it describes all my tests. (Below, truncated but it goes on like this for a while).
[{"rootid": ".", "root": "/mnt/c/Users/Scott/Documents/Documents/Coding/monaco", "parents": [{"id": "./tests", "kind": "folder", "name": "tests", "parentid": ".", "relpath": "./tests"}, {"id": "./tests/test_MCCase.py", "kind": "file", "name": "test_MCCase.py", "parentid": "./tests", "relpath": "./tests/test_MCCase.py"}, {"id": "./tests/test_MCSim.py", "kind": "file", "name": "test_MCSim.py", "parentid": "./tests", "relpath": "./tests/test_MCSim.py"}, {"id": "./tests/test_MCSim_io.py", "kind": "file", "name": "test_MCSim_io.py", "parentid": "./tests", "relpath": "./tests/test_MCSim_io.py"}, {"id": "./tests/test_MCVal.py", "kind": "file", "name": "test_MCVal.py", "parentid": "./tests", "relpath": "./tests/test_MCVal.py"},
prima facie it seems that either
the directory saved in settings.json is different from your actual working directory or
Something wrong with the installation of pytest which the VS code can access,
while the one from the terminal seems to be working as you said.
Anyway, to help you we need more info.
your folder structure, files list, etc
how you installed python, pytest and linked it with VS code
output of
> ~/.cache/pypoetry/virtualenvs/myproject-bfS1OgpY-py3.9/bin/python ~/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/coding/myproject/tests -s --cache-clear .
cwd: ~/coding/myproject/tests
even if it is gibberish
any other info you think could help and have forgotten to include here
I figured this out. It turns out that the only reason pytest was working at all, was because I had installed the package locally and the test imports were keying off the local files via that package installed in editable mode (this happens with poetry install or pip install -e).
I started from a clean python environment, and got pytest working by using the "conftest" answer to this stackoverflow question. My tests show up now!
Edit 2022-01-24: I am running into this issue again, and unfortunately a clean environment is not working any more.

How to install vscode extension that is being developped locally from an unpacked directory

I am developping a VSCode extension that I want to try it out in the current VSCode instance, not in a new instance.
Is there a way to install the vscode extension that is developping locally from an unpacked directory, not from a .vsix file.
In Atom editor, I can use atom link to do that. Is there something similar in VSCode?
You can install the extension locally with code --install-extension and install a locally packaged extension. I am doing this with esbuild and yarn:
package.json
"scripts": {
"vscode:prepublish": "yarn run build:base --minify",
"build:base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"build": "yarn build:base --sourcemap",
"package": "mkdirp dist && vsce package -o dist/noteberry.vsix --yarn",
"deploy:local": "yarn package && code --install-extension dist/ext.vsix --force"
...
},
mkdirp is an npm module to create folders.
Original Post
One easy solution without packaging as described in https://vscode-docs.readthedocs.io/en/stable/extensions/install-extension/ would be:
VS Code looks for extensions under your extensions folder
.vscode/extensions. Depending on your platform it is located:
Windows %USERPROFILE%\.vscode\extensions
Mac $HOME/.vscode/extensions
Linux $HOME/.vscode/extensions
If you want to load your extension or customization each time VS Code
runs, copy your project to a new folder under .vscode/extensions.
You could write a script to delete / copy over all files.