I migrated my vue3 project today from Webpack to Vite.
To make font awesome work I used the SVG plugin for vite and everything works correct in dev mode.
As soon as I want to build my project I get an syntax error
SyntaxError: Unexpected token
Which is caused by the fontawesome-svg-core package in line 463 which is the following
if (!promise._handled && isNode) {
global.process.emit('unhandledRejection', promise._data, promise);
}
This error makes no sense to me, anybody knows how to fix is or where I went wrong during my migration?
Thanks in advance
I am trying to create a DiffMerge like app that will show me differences between Rhapsody diagrams more friendly.
I did some research and I found out that someone did a .sbs to .xml file convertor[1], which then can be parsed easily.
Now, when I try to compile the file using make all I get this error:
flex lexer.l
gawk "/#define YY_BUF_SIZE/{gsub(/16384/, "(1024*1024)")};{print}" lex.yy.c > lex.yy.c.new
/bin/sh: 1: Syntax error: "(" unexpected
make: *** [flex] Error 2
Could you help me solve this?
The files I used are on the Git link below.
Note: I commented the line with SHELL=... from Makefile because I'm working in Linux.
[1] https://github.com/PrzemekWirkus/sbs2xml-conv
Just change the "s around the script to 's (which they always should be anyway):
gawk '/#define YY_BUF_SIZE/{gsub(/16384/, "(1024*1024)")};{print}' lex.yy.c > lex.yy.c.new
Flow seems to generate a lot of errors on a new project. What am I doing wrong ?
What I did:
Created a new React Native project using react-native init FlowProject
Followed the set-up for Flow with yarn and Babel
yarn add --dev babel-cli babel-preset-flow
yarn add --dev flow-bin
Ran yarn run flow (.flowconfig was generated by the init)
Here is the error I get:
.flowconfig:53 Unsupported option specified! (unsafe.enable_getters_and_setters)
error Command failed with exit code 8.
Now if I remove the specified line (and version number), I get a bunch of these two errors:
Error: node_modules/react-native/Libraries/Inspector/Inspector.js:104
104: clearTimeout(_hideWait);
^^^^^^^^^ null. This type is incompatible with the expected param type of
733: declare function clearTimeout(timeoutId?: TimeoutID): void;
^^^^^^^^^ TimeoutID. See lib: /private/tmp/flow/flowlib_171966cc/core.js:733
Error: node_modules/react-native/Libraries/Lists/VirtualizedList.js:1094
1094: this.props.onEndReachedThreshold * visibleLength / 2;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ undefined. The operand of an arithmetic operation must be a number.
Found 19 errors
error Command failed with exit code 2.
If I delete the generated .flowconfig file (see at the end), recreate it with yarn run flow init, and run yarn run flow again, I get the following errors (I'm just showing those 5, most of them were similar to each other):
Error: node_modules/react-native/Libraries/Animated/src/AnimatedEvent.js:101
101: if (__DEV__) {
^^^^^^^ __DEV__. Could not resolve name
Error: node_modules/react-native/Libraries/Inspector/Inspector.js:104
104: clearTimeout(_hideWait);
^^^^^^^^^ null. This type is incompatible with the expected param type of
733: declare function clearTimeout(timeoutId?: TimeoutID): void;
^^^^^^^^^ TimeoutID. See lib: /private/tmp/flow/flowlib_15451c3f/core.js:733
Error: node_modules/react-native/Libraries/Interaction/InteractionManager.js:107
107: return promise.done(...args);
^^^^^^^^^^^^^^^^^^^^^ call of method `done`. Function cannot be called on
107: return promise.done(...args);
^^^^^^^^^^^^^^^^^^^^^ property `done` of unknown type
Error: node_modules/react-native/Libraries/Interaction/TaskQueue.js:165
165: .done();
^^^^ property `done`. Property not found in
v---------
152: task.gen()
153: .then(() => {
154: DEBUG && infoLog(
...:
164: })
-^ Promise
Error: node_modules/react-native/Libraries/Lists/VirtualizedList.js:1016
1016: distanceFromEnd < onEndReachedThreshold * visibleLength &&
^^^^^^^^^^^^^^^^^^^^^ undefined. The operand of an arithmetic operation must be a number.
... 16 more errors (only 50 out of 66 errors displayed)
To see all errors, re-run Flow with --show-all-errors
error Command failed with exit code 2.
Now I know that I can tell flow to ignore certain files, but first, it seems weird to me that flow gives me these errors for code that I have not produced. I've also seen on a github issue that we shouldn't tell flow to ignore the node_modules. So is the solution to ignore every single file that this first flow analysis gives us ?
Here's a list of the files concerned:
Error node_modules/react-native/Libraries/Inspector/Inspector.js:
Error node_modules/react-native/Libraries/Interaction/InteractionManager.js
Error node_modules/react-native/Libraries/Lists/FlatList.js
Error node_modules/react-native/Libraries/Lists/ViewabilityHelper.js
Error node_modules/react-native/Libraries/Lists/VirtualizedList.js
Error node_modules/react-native/Libraries/Lists/VirtualizedSectionList.js
Error node_modules/react-native/Libraries/StyleSheet/flattenStyle.js
Generated .flowconfig file
[ignore]
; We fork some components by platform
.*/*[.]android.js
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Ignore unexpected extra "#providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
; Ignore polyfills
.*/Libraries/polyfills/.*
; Ignore metro
.*/node_modules/metro/.*
[include]
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/react-native/flow-github/
[options]
emoji=true
module.system=haste
munge_underscores=true
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
unsafe.enable_getters_and_setters=true
[version]
^0.61.0
You cannot delete the React Native .flowconfig, because it defines a lot of custom configuration required for the project to typecheck cleanly.
Let's instead look at the initial error:
.flowconfig:53 Unsupported option specified! (unsafe.enable_getters_and_setters)
error Command failed with exit code 8.
This is caused by the version of Flow you installed with yarn add flow-bin no longer supporting this option (It was removed in 0.62). You'll need to install the exact version of Flow defined on the last line of your .flowconfig
[version]
^0.61.0
You can do this with:
yarn add flow-bin#0.61
Now the project should type check correctly.
Note that in the future, if you upgrade your project template with react-native upgrade and you accept the changes to .flowconfig, you may need to manually upgrade your flow-bin dependency to match.
Found this semi-related issue which recommended updating the flowconfig to use the latest version from create-react-native-app. Seems to have worked for me.
Go to .flowconfig file in your root project folder.
Delete this lines:
esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable
Done!
On every view in my cakephp3-app cake tries to write to cli-error.log. Why? I have no idea how to debug this...
Warning: file_put_contents(/home/matthias/www/bserp.localhost/logs/cli-error.log): failed to open stream: Permission denied in /home/matthias/www/bserp.localhost/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 134
//debug(array('php_sapi_name' => php_sapi_name()));
[
'php_sapi_name' => 'apache2handler'
]
Maybe this was the most stupid error ever happend to me. I accidentay copy/pasted the warning in plain text into the config/route.php file of an plugin.
So apache didn't drop this warning but just printed text in the file.
sorry for beeing an idiot :)
I have a long script that was not written by me. When i run it I get:
phantomjs file.js
SyntaxError: Parse error
i checked out the manual and --help, and the best i could came up with was:
phantomjs --debug=yes file.js
(irrelevant debug statement from CookieJar)
SyntaxError: Parse error
Is there any better way to get at least a line number? or any hint at all?
Run the file with node. If there is a parse error it will report it.
If the file is valid, then node will also try to run it, which will fail if your script depends on something not available in your node environment. So you'll have to ignore any runtime errors.
For example, given hello-world.js:
// Say Hello World twice
for (var i=0; i<2; i++) {
console.log("Hello World") );
}
Run it with node:
node hello-world.js
Output:
/home/someone/somewhere/hello-world.js:3
console.log("Hello World") );
^
SyntaxError: Unexpected token )
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Your file.js contains an invalid syntax. You should check it with a syntax validator. An online tool which I have created can be one possible solution, check out http://esprima.org/demo/validate.html.
Getting More Information From PhantomJS
The next version of PhantomJS (presumably it will be 1.9.8, whatever comes after 1.9.7) will output errors like this:
SyntaxError: Parse error
http://localhost:9000/scripts/49e8b4f4.vendor.js:8
So that's slightly more useful than the current message.
Unfortunately there are no nightly builds for PhantomJS, so at this time you will need to compile your own version of master if you want to try this.
Debugging Minified files
If you are working with a minified file, often the line number won't be very helpful, and often debugging the un-minified file won't give you the parse error.
To solve this, once you get phantomjs to give you the name of the file, you can use the online demo of Esprima to get an actual parse of your JavaScript code:
http://esprima.org/demo/parse.html
From there, you can enter strategic line breaks to isolate the actual error.
Lint Tools are Sub-optimal for this use-case
A lint tool like jslint or jshint are more opinionated than a real parser, so if you are looking for a very specific syntax error, I would recommend using a real parser, since it will check only for code validity, and not opinionated styling guidelines. I'm not implying lint tools don't have value, just that they won't be as helpful for solving this type of problem.
You can also use syntax linters like jslint or jshint
I received SyntaxError: Parse error while trying to require a custom minified jquery.
I found the solution was to add a blank line to the bottom of jquery.min.js.
Hopefully this helps someone. Using PhantomJS 1.9.7.
I use a simple shell script that will run Phantom normally if no parse errors are found, otherwise it will display the errors. It runs the script through node, checks for SyntaxError in the output and then re-runs node to the terminal if there are errors. It passes all the command line arguments along to Phantom.
Failure mode for this method is if your node parser is significantly different from your Phantom parser. Mine are close enough that it's never been a problem.
usage: ./debug.sh --myArg1 val1 --myArg2 val2
debug.sh:
ERROR=$(node myscript.js 2>&1 >/dev/null | grep "SyntaxError")
if [ "$ERROR" = "" ]; then
echo "No parse errors, running script..."
# run the script with Phantom and pass all the args to it
phantomjs accession.js $*
else
echo "*********************************************************"
echo "********* There are parse errors in the script: *********"
echo "*********************************************************"
# show the errors by running again but not redirecting
node accession.js
fi
I did have the same issue, but none of the solutions worked for me.
I figured that the issue was probably an unsupported syntax by PhantomJS's webkit, since my page was working correctly in current browsers' versions.
What I did was finding out which webkit version PhantomJS was using, for 1.9.* it's here, 34.534.
Now we have to find the Chromium version using the same webkit, or close to it, in here (for Mac).
Ended up going with the Mac OSX 267668 and installed it.
Loaded the same URL as PhantomJS, and here it was, a real Uncaught SyntaxError: Unexpected token with a full stack trace.
Hope that helps.