Getting a filename from react-scripts build? - reactjs

I am using yarn to run react-scripts build on a private Typescript repository. The build fails with the following message:
yarn build -v
yarn run v1.22.17
$ react-scripts build -v
Creating an optimized production build...
Failed to compile.
TS2322: Type 'string | undefined' is not assignable to type 'string | number | boolean'.
Type 'undefined' is not assignable to type 'string | number | boolean'.
114 | withCredentials: true,
115 | headers: {
> 116 | Authorization: token ? `Bearer ${token}` : undefined,
| ^^^^^^^^^^^^^
117 | },
118 | });
119 |
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I understand the error, but I cannot find what file the error is in because react-scripts build doesn't seem to output the file name? I'm not sure if this is a problem with my local configuration but is there a way to get react-scripts to tell me where exactly this error is?

Related

This React project by Handsontable on codesandbox works, but when I fork or clone, it stops functioning

Here is the link to my fork on codesandbox that is having the error. I'm having the same error when I clone or download all the files and start a repo from scratch locally:
https://codesandbox.io/p/github/partorican/cdris1.0.7/main?file=%2FREADME.md
Here is the link to the first forked version that functions properly:
https://codesandbox.io/s/handsontable-react-data-grid-hello-world-app-forked-0dc85s
Here is the error I'm receiving:
Failed to compile.
src/hooksCallbacks.ts
Line 90:23: Parsing error: Unexpected token, expected ","
88 | if (headerAlignments.has(column.toString())) {
89 | Handsontable.dom.removeClass(
> 90 | TH.firstChild as HTMLElement,
| ^
91 | alignmentClass
92 | );
93 | Handsontable.dom.addClass(
Why is this error occurring? My friend and I tried several different ways on our own systems and the same error occurs, just like it does on codesandbox.
Thank you for any assistance you can provide!

Jest complains about Typescript syntax

When I run yarn test Jest throws an error that says
'Const declarations' require an initialization value.
Which is not what I'm doing!
> 4 | const config: HardhatUserConfig = {
| ^
5 | solidity: "0.8.9",
6 | paths: {
7 | artifacts: "./src/artifects",
I think it is obvious that jest is having problem with TS syntax.
How can I fix that?
You need to use ts-jest.
Install ts-jest: npm install ts-jest -D
Update your jest config to use: preset: 'ts-jest'
You still run your tests the same way - just run jest.

How to ignore .stories.tsx file on COPY command in dockerignore?

I have a reactjs app that I want to dockerize, but when I try to run:
yarn install --production
and when I try to build it with
yarn build
It comes up with this error
TS2307: Cannot find module '#storybook/react' or its corresponding type declarations.
3 | import React from 'react';
4 |
> 5 | import {ComponentStory, ComponentMeta} from '#storybook/react';
| ^^^^^^^^^^^^^^^^^^
6 |
7 | import Button from './Button';
8 |
I'm able to solve it by putting #storybook/react": "^6.4.22 in the dependencies instead of devDependencies
Is there any way to ignore all files with .stories.tsx format in dockerignore file or ignore those file format when building the app?
I've tried **/*.stories.tsx, **.stories.tsx but the file still copied inside the WORKDIR

How to get a code coverage report with react-create-app?

If I run
npm test --coverage
the tests pass, but the coverage is not run.
When I change package.json to have
react-scripts test --coverage
Then, when I do npm test and a it runs the tests but not the coverage
The tests run along with the coverage report but the coverage shows all zeroes for coverage
PASS src/components/Header/SubHeader.test.js
The <SubHeader /> component
✓ should render (4ms)
✓ should render with a goback button (1ms)
✓ should render
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 3 passed, 3 total
Time: 1.077s
Ran all test suites.
Finally, I realized that I can do
npm run test .
Question: Why don't the other methods work?
After revisiting this question i figured out that if you run this you will trigger coverage command and get all results.
SOLUTION 1
npm run test -- --coverage .
When you are passing arguments to npm script, you need to add -- before adding arguments like --coverage. This is just how npm works. See this answer for passing arguments to npm
SOLUTION 2
yarn test --coverage .
EDIT:
I asked a question regarding . being passed down the command and answer is pretty much simple. . is passed because it is a positional parameter, in contrast to --coverage that is option for npm test command: Why is . passed as argument to npm without -- delimiter?
---- Problem analysis ----
PROBLEM 1
npm test --coverage you are not passing --coverage argument to test script.
In the other case when you edit script to be:
react-scripts test --coverage and run npm test here you actually add argument --coverage, but in script itself, not from npm command
PROBLEM 2
When you do npm run test . you are passing . that means you want to include all files in this command.
For some reason . is passed to the npm run test script but not --coverage.
On the other side yarn passes all arguments without --.

DTN in OpenEmbedded for BeagleBoard

I'm trying to build the DTN using OpenEmbedded. Unfortunately, DTN
uses Tcl 8.3 or 8.4 and DB 4.2, 4.3, 4.4 or 4.5, but bitbake is using
Tcl 8.5 and DB 5.0.
In the OpenEmbedded recipes directory, among other other files there exists:
db/
db/db_4.3.29.bb
db/db4-native.inc
db/db3-native_3.2.9.bb
db/db_5.0.21.bb
db/db3-3.2.9
db/db4.inc
db/files
db/db-native_4.3.29.bb
db/db3_3.2.9.bb
db/db-native_5.0.21.bb
db/db5.inc
tcltk/
tcltk/tk
tcltk/tk_8.4.19.bb
tcltk/tcl-native_8.4.19.bb
tcltk/tk-8.5.8
tcltk/tk-native_8.4.19.bb
tcltk/tk_8.5.8.bb
tcltk/files
tcltk/tcl
tcltk/tcl-8.5.8
tcltk/tcl_8.5.8.bb
tcltk/tcl_8.4.19.bb `
At some point when the bitbake was configuring the dtn, the following happens:
| checking for library containing pow... -lm
| checking for library containing dlopen... -ldl
|
| configure: checking for tcl installation (version 8.4)
| checking for tcl.h (version 8.4) in /opt/OpenEmbedded/build/tmp/sysroots/armv7a-angstrom-linux-gnueabi usr/include... no
|
| configure: checking for tcl installation (version 8.3)
| checking for tcl.h (version 8.3) in /opt/OpenEmbedded/build/tmp/sysroots/armv7a-angstrom-linux-gnueabi/usr/include... no
| configure: error: can't find usable tcl.h
NOTE: Task failed: /opt/OpenEmbedded/build/tmp/work/armv7a-angstrom-linux-gnueabi/dtn-2.5.0-r5/temp/log.do_configure.27117
ERROR: TaskFailed event exception, aborting
ERROR: Build of /opt/OpenEmbedded/openembedded/recipes/dtnrg/dtn_2.5.0.bb do_configure failed
ERROR: Task 11 (/opt/OpenEmbedded/openembedded/recipes/dtnrg/dtn_2.5.0.bb, do_configure) failed
NOTE: Tasks Summary: Attempted 897 tasks of which 883 didn't need to be rerun and 1 failed.
ERROR: '/opt/OpenEmbedded/openembedded/recipes/dtnrg/dtn_2.5.0.bb' failed `
To solve this I went to the dtn_2.5.0.bb and added --with-tclver=8.5.
The same thing happened with DB and to solve it again I did the same thing.
After a while, when bitbake was compiling the following happened:
| In file included from storage/BerkeleyDBStore.cc:35:
| storage/BerkeleyDBStore.h:31:2: error: #error "must use Berkeley DB major version 4"
| In file included from /opt/OpenEmbedded/build/tmp/sysroots/i686-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.3.3/../../../../
arm-angstrom-linux-gnueabi/include/c++/4.3.3/ext/hash_set:64,
| from storage/../util/StringUtils.h:39,
| from storage/DurableStore.h:35,
| from storage/BerkeleyDBStore.h:39,
| from storage/BerkeleyDBStore.cc:35:
| /opt/OpenEmbedded/build/tmp/sysroots/i686-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.3.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.3.3/backward/backward_warning.h:33:2: warning:
warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date.
Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
| storage/BerkeleyDBStore.cc: In member function 'virtual int oasys::BerkeleyDBStore::init(const oasys::StorageConfig&)':
| storage/BerkeleyDBStore.cc:129: warning: invalid conversion from 'void ()(const char, char*)' to 'void ()(const DB_ENV, const char*, const char*)'
| storage/BerkeleyDBStore.cc:187: error: 'DB_LOG_AUTOREMOVE' was not declared in this scope
| make1: *** [storage/BerkeleyDBStore.o] Error 1
| make1: Leaving directory ``/opt/OpenEmbedded/build/tmp/work/armv7a-angstrom-linux-gnueabi/dtn-2.5.0-r5/dtn-2.5.0/oasys'
| make: * [oasys] Error 2
| FATAL: oe_runmake failed
NOTE: Task failed: /opt/OpenEmbedded/build/tmp/work/armv7a-angstrom-linux-gnueabi/dtn-2.5.0-r5/temp/log.do_compile.5339
ERROR: TaskFailed event exception, aborting
ERROR: Build of /opt/OpenEmbedded/openembedded/recipes/dtnrg/dtn_2.5.0.bb do_compile failed
ERROR: Task 13 (/opt/OpenEmbedded/openembedded/recipes/dtnrg/dtn_2.5.0.bb, do_compile) failed
NOTE: Tasks Summary: Attempted 913 tasks of which 913 didn't need to be rerun and 1 failed.
ERROR: '/opt/OpenEmbedded/openembedded/recipes/dtnrg/dtn_2.5.0.bb' failed `
So, is there any way to 'tell' bitbake or OpenEmbedded to use a version selected by me?
You specify versions of packages in the BOM.

Resources