How config React to render .js - reactjs

I'm trying to let WebStorm to render the .js files for me watching .jsx files.
I'm using or trying to use browserify/babelify and react nodes but I'm getting the following error
/usr/local/bin/browserify -t [babelify --presets react]
/Users/myUser/Developer/ApacheRoot/JsFrameworksSamples/ReactJs/Sample_2/src/*
-o /Users/myUser/Developer/ApacheRoot/JsFrameworksSamples/ReactJs/Sample_2/src/bundle.js
Error: Cannot find module
'/Users/myUser/Developer/ApacheRoot/JsFrameworksSamples/ReactJs/Sample_2/src/*'
from
<br>'/Users/myUser/Developer/ApacheRoot/JsFrameworksSamples/ReactJs/Sample_2/src'
at <br>/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:55:21
at load <br>(/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
at onex <br>(/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
at <br>/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
at<br> FSReqWrap.oncomplete (fs.js:95:15)<br>
Process finished with exit code 1
The configuration for the file watcher is the following:
arguments: -t [babelify --presets react] $FileDir$/* -o $FileDir$/bundle.js
What am I doing wrong?

OK....I got the solution...
browseify cannot use wildcard (as *) so it should transpile individual files using the following arguments:
-t [babelify --presets react] $FileDir$/$FileNameWithoutExtension$.jsx -o $FileDir$/../dist/$FileNameWithoutExtension$.js
after that when you want to bundle all .jsx files, it can run the following command:
browserify -t [ babelify --presets [ react ] ] src/* -o dist/bundle.js

Related

React-native-rn tailwind doesn't generate tailwind.json

I followed all the steps of installing react-native-rn.
Everything worked fine at first, but when I moved input.cssto src/css/input.css,it just generates src/css/tailwind.css, but not the src/css/tailwind.json file
I did modify the lines at package.json so they look like this.
"build:tailwind": "tailwindcss --input ./src/css/input.css -o ./src/css/tailwind.css --no-autoprefixer && tailwind-rn",
"dev:tailwind": "concurrently \"tailwindcss -i ./src/css/input.css -o ./src/css/tailwind.css --no-autoprefixer --watch\" \"tailwind-rn --watch\""
This is basically how my directory looks (I hided folders as node_modules, android, etc)
At the end of either command in package.json you'll see they both have tailwind-rn, basically what the command does is: take this file (tailwind.css) and compile it to (tailwind.json)
So, because you changed the path, default values (react-native-rn --input tailwind.css --output tailwind.json) don't work.
Manually add at the end of the commands react-native-rn --input path/to/the/generated/css.css --output path/to/where/you/want/your/json.json
In this example, it this would be:
-i equals to --input, and -o to --ouput
"build:tailwind": "tailwindcss --input ./src/css/input.css -o ./src/css/tailwind.css --no-autoprefixer && tailwind-rn -i ./src/css/tailwind.css -o ./src/css/tailwind.json",
"dev:tailwind": "concurrently \"tailwindcss -i ./src/css/input.css -o ./src/css/tailwind.css --no-autoprefixer --watch\" \"tailwind-rn -i ./src/css/tailwind.css -o ./src/css/tailwind.json\""
Also remember to edit App.js imports
//from
import utilities from './tailwind.json';
//to
import utilities from './src/css/tailwind.json';

ERROR: Failed to spawn fakeroot worker to run /PATH_TO_THIS/example_0.1.bb:do_install: [Errno 2] No such file or directory

I am trying to compile a c code and install it using yocto. it is successfully compiled using do_compile.
I tried to install using do_install, it is giving bellow error.
ERROR: Failed to spawn fakeroot worker to run /PATH_TO_THIS/example_0.1.bb:do_install: [Errno 2] No such file or directory
Please find my bb file below
SUMMARY = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR} /MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://sample.c"
S = "${WORKDIR}"
do_compile() {
x86_64-linux-gnu-gcc sample.c -o test_example
}
do_install() {
install -d ${D}${bindir}
install -m 0755 test_example ${D}${bindir}
}
Based on your comment above that you are using -b - that is almost certainly the cause of this issue. When you use -b bitbake will print this warning:
WARNING: Buildfile specified, dependencies will not be handled. If this is not what you want, do not use -b / --buildfile.
One of the dependencies that you may be missing is the fakeroot program (pseudo). Using -b is likely preventing that from being built.
Instead of using -b, you should put the recipe into a place bitbake can find it (to test, could be meta/recipes-extended/example, but when you do it properly you should create your own layer and put it there). Then you can just build it like any other recipe:
bitbake example

Why I keep get error like unexpected token when follow React.js tutorial

[UPDATE]: It turns out that I did not follow exactly as official sites says, which means I need add "[ ]" in the command.
All:
I am pretty new to react.js, when I follow official site tutorial, the steps I used is:
A. Build a file main.js
B. npm install -g browserify
C. npm install --save react react-dom babelify babel-preset-react
D. browserify -t babelify --presets react main.js -o bundle.js
Then I get error like:
SyntaxError: c:/Temp/web/lnreact/main.js: Unexpected token (6:2)
4 |
5 | ReactDOM.render(
> 6 | <h1>Hello, world!</h1>,
| ^
7 | document.getElementById('example')
8 | );
at Parser.pp.raise (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel-core\node_modul
es\babylon\index.js:1413:13)
at Parser.pp.unexpected (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel-core\node_
modules\babylon\index.js:2895:8)
at Parser.pp.parseExprAtom (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel-core\no
de_modules\babylon\index.js:746:12)
at Parser.pp.parseExprSubscripts (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel-c
ore\node_modules\babylon\index.js:501:19)
at Parser.pp.parseMaybeUnary (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel-core\
node_modules\babylon\index.js:481:19)
at Parser.pp.parseExprOps (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel-core\nod
e_modules\babylon\index.js:412:19)
at Parser.pp.parseMaybeConditional (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel
-core\node_modules\babylon\index.js:394:19)
at Parser.pp.parseMaybeAssign (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel-core
\node_modules\babylon\index.js:357:19)
at Parser.pp.parseExprListItem (c:\Temp\web\lnreact\node_modules\babelify\node_modules\babel-cor
e\node_modules\babylon\index.js:1224:16)
at Parser.pp.parseCallExpressionArguments (c:\Temp\web\lnreact\node_modules\babelify\node_module
s\babel-core\node_modules\babylon\index.js:577:20)
I am wondering where did I do wrong?
Thanks
You do not appear to be running the command given in the tutorial. The correct command to run browserify should be this:
$ browserify -t [ babelify --presets [ react ] ] main.js -o bundle.js

Pkg-config file is on the pkg-config path but can not be found by configure script

I am trying to install libvirt from source. The version I am trying to install is 1.2.7. I want libssh2 enabled. Here is how I call the configure script:
./configure --prefix=/home/administrator/dev/workspaces/libvirt/built/libvirt-1.2.7/ --with-sasl --with-qemu --with-lxc --with-gnutls --with-remote --with-ssh2 --with-polkit
I got the following error:
configure: error: You must install the libssh2 >= 1.3 pkg-config module to compile libvirt
I downloaded the libssh2 lib version 1.4.3 and installed it using the default options:
$ ./configure
$ make
$ sudo make install
Here is some useful info:
$ sudo ldconfig
$ sudo updatedb
$ locate libssh2.so
/usr/local/lib/libssh2.so
/usr/local/lib/libssh2.so.1
/usr/local/lib/libssh2.so.1.0.1
$ locate libssh2.pc
/usr/local/lib/pkgconfig/libssh2.pc
$ pkg-config --variable pc_path pkg-config
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
Obviously the libssh2.pc file is on the pkg-config path. However, when I tried executing the configure script for libvirt, the same error occurred. Any ideas what I am doing wrong ? Thank you.
EDIT: Fragment of the config.log file:
34475 configure:59141: checking for SSH2
34476 configure:59148: $PKG_CONFIG --exists --print-errors "libssh2 >= 1.3"
34477 configure:59151: $? = 0
34478 configure:59165: $PKG_CONFIG --exists --print-errors "libssh2 >= 1.3"
34479 configure:59168: $? = 0
34480 configure:59182: result: no
34481 Package libssl was not found in the pkg-config search path.
34482 Perhaps you should add the directory containing `libssl.pc'
34483 to the PKG_CONFIG_PATH environment variable
34484 Package 'libssl', required by 'libssh2', not found
34485 configure:59225: error: You must install the libssh2 >= 1.3 pkg-config module to compile libvirt
...
34576 ac_cv_env_PKG_CONFIG_LIBDIR_set=
34577 ac_cv_env_PKG_CONFIG_LIBDIR_value=
34578 ac_cv_env_PKG_CONFIG_PATH_set=
34579 ac_cv_env_PKG_CONFIG_PATH_value=
34580 ac_cv_env_PKG_CONFIG_set=
34581 ac_cv_env_PKG_CONFIG_value=
...
34874 ac_cv_path_ac_pt_PKG_CONFIG=/usr/bin/pkg-config
36432 PKG_CONFIG='/usr/bin/pkg-config'
36433 PKG_CONFIG_LIBDIR=''
36434 PKG_CONFIG_PATH=''

run one test by name from one nodeunit file

Is it possible to run only one test from nodeunit test file with several tests. My tests.js file:
module.exports = {
test2: function (test) {
console.log ("test2")
test.done();
},
test1: function (test) {
console.log ("test1")
test.done();
}
};
I can run all tests:
$ nodeunit tests.js
But I want to run only test2 like:
$ nodeunit tests.js test2
Is it possible without spliting file tests.js into 2 separate files?
See nodeunit -h for the available options (This is for version 0.8.1):
Usage: nodeunit [options] testmodule1.js testfolder [...]
Options:
--config FILE the path to a JSON file with options
--reporter FILE optional path to a reporter file to customize the output
--list-reporters list available build-in reporters
-t name, specify a test to run
-f fullname, specify a specific test to run. fullname is built so: "outerGroup - .. - innerGroup - testName"
-h, --help display this help and exit
-v, --version output version information and exit
So from that the following should do what you want:
$ nodeunit tests.js -t test2
e.g:
$ nodeunit ./tests.js -t test2
tests.js
test2
✔ test2

Resources