Getting SyntaxError: Unexpected identifier
See original GitHub issue🐛 Bug report
Current Behavior
When I am building on my server, I am getting this error
/var/www/lite-2/valkyrie/node_modules/lodash-es/clone.js:1
(function (exports, require, module, __filename, __dirname) { import baseClone from './_baseClone.js';
^^^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
/var/www/lite-2/valkyrie/node_modules/lodash-es/clone.js:1
(function (exports, require, module, __filename, __dirname) { import baseClone from './_baseClone.js';
Upon looking I found that formik
is the only npm module, that is using lodash-es behind the scene.
Expected behavior
The build should go seamless.
Reproducible example
Suggested solution(s)
By using lodash instead of lodash-es
Additional context
Your environment
Software | Version(s) |
---|---|
Formik | 1.5.8 |
React | 16.8.1 |
TypeScript | na |
Browser | na |
npm/Yarn | 6.4.1/1.17.3 |
Operating System | Ubuntu 14.04.5 LTS |
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
How To Solve The Unexpected Identifier Error in JavaScript
It will look through your code and if it detects any errors it will tell you specifically where that error exists.
Read more >A Common Cause of "Uncaught syntax error - Techstacker
A Common Cause of "Uncaught syntax error: unexpected identifier" in JavaScript ... One of the most common reasons is that you're trying to...
Read more >Unexpected Identifier in Chrome's Javascript console
I got SyntaxError: Unexpected identifier error, for invalid order between async and static, static must come first.
Read more >How to Fix "Uncaught SyntaxError: Unexpected identifier" in ...
In this post, we looked at what causes the Uncaught SyntaxError: Unexpected identifier error and how to fix it. In most cases, it...
Read more >SyntaxError: Unexpected identifier - Codecademy
SyntaxError : Unexpected identifier ... I'm trying to create a program which asks the user what they're favorite Big Ten team is, checks...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@deeksha-agarwal just curious why this issue was closed. Do you know why Formik is using lodash-es at all? It seems like we should be able to get away with just using lodash… I’m running into a situation where i’m importing both lodash (for my project) and then another copy of lodash-es so I get double the size.
would be happy to dive in and see if I can submit a PR to remove it and just use core lodash.
cc: @jaredpalmer
@nikitaindik after doing some research on this, it appears Formik uses a TypeScript development tool called tsdx. This appears to reference lodash in their docs.
It looks like this tool requires the inclusion of lodash-es. This is supposed to be to avoiding bloating the bundle but I’m not sure this is actually getting accomplished based off our bundle analyzer results as both lodash and lodash-es were getting included into the Formik bundle.
Maybe I’m missing something here, @jaredpalmer may have some thoughts on this? Seem to specific to tsdx and not Formik so probably can’t fix this here.