Windows 10 failure to compile with Node and React - syntax errors? - node.js

I've been trying to start up a React project but can't avoid the following syntax error message. I've tried Yarn only to run into more errors (that would be for another post). My coworkers have no trouble running this on their Macs, so I'm wondering if it's a Windows specific issue? Totally lost on this one:
./src/ducks/auth/index.js
Syntax error: C:/Users/user/code/project/src/ducks/auth/index.js: Unexpected
token, expected ; (5:20)
3 | export * from './constants';
4 |
> 5 | export default from './reducer';
| ^
6 |
7 | export * from './selectors';

Are you importing or exporting? Your syntax looks half and half right now. If you are exporting:
export default <name of function>
if you are importing:
import <name of default function> from './reducer
edit: Now that I look at it, you're obviously importing. When importing, you have to state the exact name of what you exported. There is no keyword default when importing. Also, you need to use import, not export.

Related

How to check if the environment variable "PROJ_LIB" is defined and how to unset it ? (PyQGIS Standalone Script Executer)

I just tried the standalone PyQGIS application by running the custom script "Proximity.py"* in a VS Code project without the need of a GUI (such as QGIS).
But, when I run the python-program I get the following message:
proj_create_from_database: C:\Program Files\PostgreSQL\14\share\contrib\postgis-3.2\proj\proj.db contains DATABASE.LAYOUT.VERSION.MINOR = 0 whereas a number >= 2 is expected. It comes from another PROJ installation. (see also: Error Message after launching the configuration (launch.json) from VS Code (when pressing F5))
I'm trying this online example with the following installations:
PostgreSQL 14
Python39
.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy\launcher
osgeo4w-setup.exe (including QGIS LTR)
I read that there is a solution by undefining [PROJ_LIB] before importing pyproj or osgeo: del os.environ ['PROJ_LIB'] as described under this link. If this is also supposed to be the correct solution in this case, can someone help me with step-by-step instructions (for dummies)?
. * The "Proximity.py" script is a pyqgis standalone example from "https://github.com/MarByteBeep/pyqgis-standalone"
Finally, I got a solution to be able to run the "standalone PyQGIS"* example "Proximity" (provided by MarByteBeep).
This solution was possible without needing to launch the configuration file "launch.json" as above described. And so, avoiding the need to make any configuration to the environment variable "PROJ_LIB" by trying to circumvent the above issue.
I just first added the following two code-lines (see here line 2 and 3) in the python file "main.py" so as to be able to use the plugin "PROCESSING" (initially line 8 of the "main.py" file), then I store it and finally I ran it.
Line 1: from qgis.core import
Line 2: import sys
Line 3: sys.path.append('C:\Program Files\QGIS 3.24.1\apps\qgis\python\plugins')
Line 4: qgs = QgsApplication([], False)
Line 5: ...
The Proximity example is based on the answer of "Mar Tjin" to the following Question: "Looking for manual on how to properly setup standalone PyQGIS without GUI"
. * By "Standalone PyQGIS" I refer to code/scripts that can be run outside the QGIS-GUI (=> QGIS-Desktop/Server Application). In my case under the external Editor VS Code

Acessing myclass defined in python file in different folder from jupyter notebook

I have following folder structure
|
|---notebook
| |
| --- MyNoteBook.ipnyb
|
|---python
| |
| --- image_rotation_utils.py
I have following content in python.image_rotation_utils.py
class ImageRotationUtils:
""" Utils for rotating images."""
def __init__(self, image_path=None, image_name=None, output_path=None, output_annotations_file=None ):
""" Initializes the class.
Args:
image_path: the relative path to the image
image_name: image file name
output_path: the relative path where rotated output file is stored.
output_annotations_file: annotations file where rotated anotations are stored.
"""
self.image_path = image_path
self.image_name = image_name
self.output_path = output_path
self.output_annotations_file = output_annotations_file
#other functions defined
Now in MyNoteBook.ipnyb I have following cells
Cell 1:
import sys
sys.path.insert(0, '..')
from python.image_rotation_utils import *
Above is executed successfully now in cell 2 I have below
myUtils = ImageRotationUtils()
I have getting below error
----> 1 ImageRotationUtils()
TypeError: __init__() missing 4 required positional arguments: 'image_path', 'image_name', 'output_path', and 'output_annotations_file'
whye I am getting this error when I have default values in constructor has None in class definition.
I am new to python and trying to put code in productive manner. What mistake I am making. Kindly provide inputs
What you pasted looks ok to me, and your code works for me without errors.
Perhaps something before or after that code is what is spoiling the class definition?
Perhaps you are running this in Jupyter or in IPython and you imported ImageRotationUtils previously, but then changed the code, and tried to reimport again -- and something was wrong with the new reimport so your definition did not get over-written? If that's the case, restart the environment (or the kernel in Jupyter) and rerun the code.
I would suggest putting a simple initialization code, like that constructor line, into the same source file and executing it as a separate process to test if that is the code or the environment issue.
As a matter of convenience and to avoid tweaking sys.path in your code, I would suggest adding your python directory to the PYTHONPATH environment variable before you load your environment, so you can just import.

Lit-Element import statement with unpkg

I have some projects with Lit-Element and all was fine till today. I had the usual import statement .
import {LitElement, html,css,} from "https://unpkg.com/lit-element#latest/lit-element.js?module";
Well I also have the option to install the library via npm but I want it to be the way it was.
Any suggestions what is wrong or how to fix it?
BTW the error in the browser:
Cannot generate module for lit-element#3.0.0-pre.3/lit-element.js
SyntaxError: unknown: Support for the experimental syntax 'nullishCoalescingOperator' isn't currently enabled (14:54):
12 | * subject to an additional IP rights grant found at
13 | * http://polymer.github.io/PATENTS.txt
14 | */var s;const i=t;((s=globalThis).litElementVersions??(s.litElementVersions=[])).push("3.0.0-pre.3");class o extends t{constructor(){super(...arguments),this.I={host:this},this.Φo=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.I).renderBefore??(t.renderBefore=e.firstChild),e}update(t){const r=this.render();super.update(t),this.Φo=e(r,this.renderRoot,this.I)}connectedCallback(){super.connectedCallback(),this.Φo?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this.Φo?.setConnected(!1)}render(){return r}}o.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:o}),globalThis.litElementPlatformSupport?.({LitElement:o});const l={O:(t,e,r)=>{t.O(e,r)},P:t=>t.P};export{o as LitElement,i as UpdatingElement,l as _Φ};
| ^
15 |
16 |
Add #babel/plugin-proposal-nullish-coalescing-operator (https://git.io/vb4Se) to the 'plugins' section of your Babel config to enable transformation.
undefined

Stories not rendering in 6.1.15 version of storybook

My main.js file:
Its not rendering stories inside Header.stories.js
Even I have explicitly included Header.stories.js but still the same issue, it's not being rendered.
Please see if anyone could help me with this as I am really stuck on this issue.
PS: Use following repo to reproduce the issue or to see the implementation!
click here to see the repo
You have this error in the console :
WARNING in ./src/components/Header.stories.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Storybook_demo/my_storybook/src/components/Header.stories.js: Const declarations require an initialization value (16:20)
14 | }
15 |
> 16 | export const Primary ()=>(<Header >'hii'</Header>);
| ^
I can see the =sign in your file, I honestly don't know why it doesn't work. It's look like a bug in a babel parser ?
However, you can make it work with juste a space between Primary and =:
export const Primary = ()=>(<Header >'hii'</Header>)

Relative Imports for two parents dir up

I have the following directory structure
code
|-----|--experiments
| |---v0
| |---agcnn.py
|-----|--pn
| |---bag
| |--run.py
run.py uses a module inside the agcnn.py. However when I try the import as following:
from experiments.v0.agccn import AG
it gives a relative import error saying no module. I'm using VScode and the the working dir is taken care by Vscode as root which is /code/ in this case.
How can I change the settings to accommodate the import ?

Resources