Webpack errors related to material-ui - node.js

I'm cloning my friend's repo on github
https://github.com/feijihn/todolist_react
with web app built on node.js + react.js + material.ui
then i'm installing requirements with npm:
npm i -S -d
after that i launch server
node server.js
and everything works perfectly, but then i make some changes and try to pack a new bundle.js thru webpack it gives me this error:
webpack --display-detailed-errors
Hash: 396f0bfb9d565b6f60f0
Version: webpack 1.12.12
Time: 1294ms
+ 1 hidden modules
ERROR in ./public/scripts/index.jsx
Module build failed: SyntaxError: /home/ignatif/todolist_react/public/scripts/index.jsx: Unexpected token (91:3)
89 | render: function() {
90 | return (
91 | <Paper className="paperE" zDepth={5}>
| ^
92 | <AppBar
93 | title="Just To-Do. No shit"
94 | iconClassNameRight="muidocs- icovigation-expand-more"/>
at Parser.pp.raise (/home/ignatif/todolist_react/node_modules/babylon/index.js:1425:13)
at Parser.pp.unexpected (/home/ignatif/todolist_react/node_modules/babylon/index.js:2907:8)
at Parser.pp.parseExprAtom (/home/ignatif/todolist_react/node_modules/babylon/index.js:754:12)
at Parser.pp.parseExprSubscripts (/home/ignatif/todolist_react/node_modules/babylon/index.js:509:19)
at Parser.pp.parseMaybeUnary (/home/ignatif/todolist_react/node_modules/babylon/index.js:489:19)
at Parser.pp.parseExprOps (/home/ignatif/todolist_react/node_modules/babylon/index.js:420:19)
at Parser.pp.parseMaybeConditional (/home/ignatif/todolist_react/node_modules/babylon/index.js:402:19)
at Parser.pp.parseMaybeAssign (/home/ignatif/todolist_react/node_modules/babylon/index.js:365:19)
at Parser.pp.parseParenAndDistinguishExpression (/home/ignatif/todolist_react/node_modules/babylon/index.js:827:26)
at Parser.pp.parseExprAtom (/home/ignatif/todolist_react/node_modules/babylon/index.js:713:19)
at Parser.pp.parseExprSubscripts (/home/ignatif/todolist_react/node_modules/babylon/index.js:509:19)
at Parser.pp.parseMaybeUnary (/home/ignatif/todolist_react/node_modules/babylon/index.js:489:19)
at Parser.pp.parseExprOps (/home/ignatif/todolist_react/node_modules/babylon/index.js:420:19)
at Parser.pp.parseMaybeConditional (/home/ignatif/todolist_react/node_modules/babylon/index.js:402:19)
at Parser.pp.parseMaybeAssign (/home/ignatif/todolist_react/node_modules/babylon/index.js:365:19)
at Parser.pp.parseExpression (/home/ignatif/todolist_react/node_modules/babylon/index.js:329:19)
at Parser.pp.parseReturnStatement (/home/ignatif/todolist_react/node_modules/babylon/index.js:2106:26)
at Parser.pp.parseStatement (/home/ignatif/todolist_react/node_modules/babylon/index.js:1894:19)
at Parser.pp.parseBlockBody (/home/ignatif/todolist_react/node_modules/babylon/index.js:2294:21)
at Parser.pp.parseBlock (/home/ignatif/todolist_react/node_modules/babylon/index.js:2275:8)
at Parser.pp.parseFunctionBody (/home/ignatif/todolist_react/node_modules/babylon/index.js:1130:22)
at Parser.pp.parseFunction (/home/ignatif/todolist_react/node_modules/babylon/index.js:2406:8)
at Parser.pp.parseFunctionExpression (/home/ignatif/todolist_react/node_modules/babylon/index.js:764:17)
at Parser.pp.parseExprAtom (/home/ignatif/todolist_react/node_modules/babylon/index.js:726:19)
at Parser.pp.parseExprSubscripts (/home/ignatif/todolist_react/node_modules/babylon/index.js:509:19)
at Parser.pp.parseMaybeUnary (/home/ignatif/todolist_react/node_modules/babylon/index.js:489:19)
at Parser.pp.parseExprOps (/home/ignatif/todolist_react/node_modules/babylon/index.js:420:19)
at Parser.pp.parseMaybeConditional (/home/ignatif/todolist_react/node_modules/babylon/index.js:402:19)
at Parser.pp.parseMaybeAssign (/home/ignatif/todolist_react/node_modules/babylon/index.js:365:19)
at Parser.pp.parseObjPropValue (/home/ignatif/todolist_react/node_modules /babylon/index.js:1021:99)
I have material-ui installed and i can't find any dependency problems myself.
My friend's webpack packs everything nicely and don't give any error. What can cause this?

The repo you provided work if you type :
npm install
webpack
node server.js

Related

Upgraded to macOS Monterey 12.3.1 and `playwright + electron` stopped working - how do I fix it?

We launch our Electron-based app like so:
test.beforeAll(async() => {
electronApp = await _electron.launch({
args: [
path.join(__dirname, '../'),
'--disable-gpu',
'--whitelisted-ips=',
'--disable-dev-shm-usage',
]
});
...
It used to work. Now the tests fail with this error message:
electron.launch: Timeout 30000ms exceeded.
61 | createDefaultSettings();
62 |
> 63 | electronApp = await _electron.launch({
| ^
You can see the tests at https://github.com/rancher-sandbox/rancher-desktop . To reproduce:
Set up:
git clone https://github.com/rancher-sandbox/rancher-desktop.git
npm i
To reproduce:
npm run test:e2e
This might be related to the node issue on Monterey 12.3.1 that it is already running on the default port 5000.
Try disabling "Airplay receiver" like this post, it worked for me.
"System Preference" -> "Sharing" -> "Airplay receiver"
Why nodeJS is not working on macOS Monterey?

SQLite3 with Electron 13

Currently trying to use sqlite3 with electron 13.1 and Node 14.17.3.
Running electron-forge start results in:
/home/victor/workplace/project/node_modules/node-addon-api/napi-inl.h: In member function ‘bool Napi::Object::Freeze()’:
/home/victor/workplace/project/node_modules/node-addon-api/napi-inl.h:1393:24: error: ‘napi_object_freeze’ was not declared in this scope; did you mean ‘napi_object_expected’?
1393 | napi_status status = napi_object_freeze(_env, _value);
| ^~~~~~~~~~~~~~~~~~
| napi_object_expected
/home/victor/workplace/project/node_modules/node-addon-api/napi-inl.h: In member function ‘bool Napi::Object::Seal()’:
/home/victor/workplace/project/node_modules/node-addon-api/napi-inl.h:1399:24: error: ‘napi_object_seal’ was not declared in this scope; did you mean ‘napi_object’?
1399 | napi_status status = napi_object_seal(_env, _value);
| ^~~~~~~~~~~~~~~~
| napi_object
⠴ Building module: sqlite3, Completed: 0../src/b
Looking at the readme of SQLite here, it seems like support for Electron 13.1 is not available.
Is there any known workaround (that I could not find) or even another (compatible) package?
I solved this by overriding the sqlite node-addon-api dependency.
If you are using yarn, you can add the following lines to the package.json file:
"resolutions": {
"sqlite3/node-addon-api": "3.1.0" }

How to compile JSX with Babel into JavaScript

I'm trying to compile the very simplest React tutorial using browserify. I've run:
sudo npm install browserify
Then as stated here http://babeljs.io/docs/setup/#browserify
sudo npm install --save-dev babelify
Then I have my file js/script.jsx
var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
ReactDOM.render(<HelloMessage name="John" />, mountNode);
And I'm running from the folder
browserify js/script.jsx -t babelify --outfile bundle.js
But then this happens:
djave at djaves-iMac-3 in /Volumes/djave/react
$ browserify js/script.jsx -t babelify --outfile bundle.js
SyntaxError: /Volumes/djave/react/js/script.jsx: Unexpected token (4:11)
2 | var HelloMessage = React.createClass({
3 | render: function() {
> 4 | return <div>Hello {this.props.name}</div>;
| ^
5 | }
6 | });
7 |
What am I doing wrong? This is literally my first step into this area so it may be I've missed a pretty major step.
More errors (although I suspect this won't help too much!)
at Parser.pp.raise (/Volumes/djave/react/node_modules/babelify/node_modules/babel-core/node_modules/babylon/index.js:1425:13)
at Parser.pp.unexpected (/Volumes/djave/react/node_modules/babelify/node_modules/babel-core/node_modules/babylon/index.js:2907:8)
at Parser.pp.parseExprAtom (/Volumes/djave/react/node_modules/babelify/node_modules/babel-core/node_modules/babylon/index.js:754:12)
at Parser.pp.parseExprSubscripts (/Volumes/djave/react/node_modules/babelify/node_modules/babel-core/node_modules/babylon/index.js:509:19)
at Parser.pp.parseMaybeUnary (/Volumes/djave/react/node_modules/babelify/node_modules/babel-core/node_modules/babylon/index.js:489:19)
at Parser.pp.parseExprOps (/Volumes/djave/react/node_modules/babelify/node_modules/babel-core/node_modules/babylon/index.js:420:19)
All fixed, thanks to #azium.
First get the React preset: http://babeljs.io/docs/plugins/preset-react/
npm install babel-preset-react
Next, create a file called .babelrc in the root of your project, and put in it the following:
{
"presets": ["react"]
}
Then do the
browserify js/script.jsx -t babelify --outfile bundle.js
That compiles everything, and as an extra to make sure that react and react-dom are included (as shown here) you can run the following:
sudo npm install --save react react-dom

What's wrong with my babel?

I have installed babel with npm install -g babel-cli and tested it with babel-node --version. The output is 6.2.0.
Then I tested it like below.
C:\Users\xuhang\Documents\work\CDT\cdt3.0\babel>babel-node
> console.log([1,2,3].map(x => x * x))
repl:1
console.log([1, 2, 3].map(x => x * x));
^^
SyntaxError: Unexpected token =>
at Object.exports.runInThisContext (vm.js:73:16)
at _eval (C:\Users\xuhang\AppData\Roaming\npm\node_modules\babel-cli\lib\_b
abel-node.js:102:26)
at REPLServer.replEval (C:\Users\xuhang\AppData\Roaming\npm\node_modules\ba
bel-cli\lib\_babel-node.js:187:14)
at bound (domain.js:254:14)
at REPLServer.runBound [as eval] (domain.js:267:12)
at REPLServer.<anonymous> (repl.js:279:12)
at REPLServer.emit (events.js:107:17)
at REPLServer.Interface._onLine (readline.js:214:10)
at REPLServer.Interface._line (readline.js:553:8)
at REPLServer.Interface._ttyWrite (readline.js:830:14)
>
Could you tell me what's wrong with console.log([1,2,3].map(x => x * x))?
Another simliar issue is below. It's so hard for me to learn babel, the initial test all failed.
What's inside the directory source is the example.js within the official sample provided by React below.
https://facebook.github.io/react/docs/tutorial.html
C:\Users\xuhang\Documents\work\CDT\cdt3.0\babel>babel source/ --watch --out-dir
build/
SyntaxError: source/example.js: Unexpected token (17:6)
15 | var rawMarkup = marked(this.props.children.toString(), {sanitize: tru
e});
16 | return (
> 17 | <div className="comment">
| ^
18 | <h2 className="commentAuthor">
19 | {this.props.author}
20 | </h2>
You've forgotten to create a .babelrc file. Pre 6.x version of Babel contained a few presets for Babel to transpile code out of the box, in 6.x it does not so you need to install the presets you want and in your case you need two: babel-preset-es2015 and babel-preset-react.
After you've installed them both npm install babel-preset-es2015 babel-preset-react add them to your .babelrc file
{
"presets": ["es2015", "react"]
}

babel-node not recognizing jsx <

I am trying to run some code that uses React and JSX using babel-node, which is part of the babel-cli. To the best of my knowledge the code is correct and I am using babel-node as expected, but hopefully someone can provide more insight.
The following error is generated.
(!535)-> babel-node server.js
/Users/eprouty/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:520
throw err;
^
SyntaxError: /Users/ep/git/dgcastle/server.js: Unexpected token (60:51)
58 | res.status(302).redirect(redirectLocation.pathname + redirectLocation.search)
59 | } else if (renderProps) {
> 60 | var html = ReactDOM.renderToString(<RoutingContext {...renderProps} />);
| ^
61 | var page = jade.renderFile('views/index.jade', {html: html});
62 | res.status(200).send(page);
63 | } else {
at Parser.pp.raise (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/location.js:24:13)
at Parser.pp.unexpected (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/util.js:91:8)
at Parser.pp.parseExprAtom (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:507:12)
at Parser.pp.parseExprSubscripts (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:260:19)
at Parser.pp.parseMaybeUnary (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:240:19)
at Parser.pp.parseExprOps (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:171:19)
at Parser.pp.parseMaybeConditional (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:153:19)
at Parser.pp.parseMaybeAssign (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:120:19)
at Parser.pp.parseExprListItem (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:966:16)
at Parser.pp.parseCallExpressionArguments (/Users/ep/.nvm/versions/v5.0.0/lib/node_modules/babel-cli/node_modules/babylon/lib/parser/expression.js:336:20)
I can provide additional code snippets if that would help but the offending block is already included in the error message. Thanks for any insight you can provide!
If you are running version 6.x of babel, you need to use the babel react preset (as stated here).
If you are using babel 6.x, you will need to install the relevant preset/plugins. To get started, you can run npm install -g babel babel-preset-react and then run babel --presets react --watch src/ --out-dir lib/. For more information: check out the babel 6 blog post

Resources