Parsing error assigning to rvalue



Parsing error assigning to rvalue

Reading time В· 2 min

SyntaxError: Assigning to rvalue in JavaScript [Solved] #

The «Assigning to rvalue» error occurs when we have a SyntaxError in our JavaScript code. The most common cause is using a single equal sign instead of double or triple equals in a conditional statement.

To solve this, make sure to correct any syntax errors in your code.

Here are some common examples where the error occurs.

The engine interprets the single equal sign as an assignment and not as a comparison operator.

Another common cause of the error is trying to set an object property that includes a hyphen using dot notation.

You should use bracket [] notation instead, e.g. obj[‘key’] = ‘value’ .

If you aren’t sure where to start debugging, open the console in your browser or the terminal in your Node.js application and look at which line the error occurred.

The screenshot above shows that the error occurred in the index.js file on line 4 .

You can paste your code into an online Syntax Validator . The validator should be able to tell you on which line the error occurred.

You can hover over the squiggly red line to get additional information on why the error was thrown.

Conclusion #

The «Assigning to rvalue» error occurs when we have a SyntaxError in our JavaScript code. The most common cause is using a single equal sign instead of double or triple equals in a conditional statement.

To solve this, make sure to correct any syntax errors in your code.

Источник

Ignore or Resolve «Parsing error: Assigning to rvalue» #9633

Comments

Tell us about your environment

  • ESLint Version: ^4.11.0
  • Node Version: v6.10.0
  • npm Version: 3.10.10 (I yarn installed eslint though)

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

What did you expect to happen?

I’m using eslint to process some JavaScript that contains «YAML front matter» used by a Jekyll static site generator. [The first three lines in the js file above are the YAML front matter for the given JS file]. Basically Jekyll requires that front matter so we can declare that a given file should be parsed by the Jekyll engine. When Jekyll processes a file with YAML front matter, it removes the front matter and replaces any values between double curly braces with values specified elsewhere. The output JS file does not have the YAML front matter (and thus begins on line 4 of the sample JS above).

Читайте также:  Error code 1146 table

When I run eslint on files with this YAML front matter, however, I get 1:3 error Parsing error: Assigning to rvalue . I’d like to resolve or ignore this error if possible. Is there any way for me to do so?

It’s worth noting that folks in this situation could use eslint against the files after Jekyll processes them, as Jekyll removes the front matter from processed files, as noted above. However, this would require one to build my site each time I want to lint the JS, and large Jekyll sites can take many seconds to build, so this would be suboptimal.

The text was updated successfully, but these errors were encountered:

Источник

flow type annotations with default parameters in arrow functions fail eslint due to Parsing error: Assigning to rvalue #190

Comments

If I have code like this:

`
let hello = (greeting:string = ‘ world’) : string => <
console.log(‘hello’ + greeting);
>;

I get a babel-eslint error.

I created a repo to help reproduce it:

For now I’ll workaround by not using default parameters, but I’d sure like them 🙂 Thanks so much!

The text was updated successfully, but these errors were encountered:

What is the error?

Ah, wow that was fast! 🙂 Sorry, forgot to paste the error:

Parsing error: Assigning to rvalue

If I don’t use arrow functions it works fine, ie:

let hello = function (greeting:string = ‘ world’) : string <
console.log(‘hello’ + greeting);
>;

This isn’t a babel-eslint issue. It’s a bug in the parser. Please report it on the babel repo.

Ok. Will do, thanks!

This link now 404s:

I eventually learned that this was because Babel has switched to Phabricator for their issue tracking, where the Phabricator URL for that issue is here:

Читайте также:  Getting error failed перевод

Annoyingly, the Phabricator issue doesn’t contain any useful information, like the related commits or the version of Babel where this was integrated . sheesh!

Yet more searching and I was eventually able to track down the commit where this was fixed:

However, the long and short of it is that you currently need to be using babel-eslint 5.0 (in Beta only at the time of writing) if you want to pick this fix up. I changed my config from ^4.1.6 to ^5.0.0-beta6 and now everything’s working great 😄 .

Источник

Browserify «Assigning to rvalue» problem. #1

Comments

Edit: tl;dr: for those of you who stumbled here by googling «Assigning to rvalue»:

The browserify parser chokes on constructs like

It should read it as foo[k] || (foo[k] = bar); , but instead it sees (foo[k] || foo[k]) = bar; and barfs.

That kind of code is actually valid JS and it is produced by minifiers (at least by uglifyjs). It is a Browserify bug (or, more likely, a bug in the underlying JS parser).

May I use j2c with browserify? Doing so results in error «Assigning to rvalue (175:6) while parsing …/node_modules/j2c/dist/j2c.commonjs.js»

Doesn’t have any issue, however, and it works in NodeJS.

The text was updated successfully, but these errors were encountered:

Here’s the stack from Browserify@10.2.3:

I can’t work out how j2c@0.7.2 which I get from NPM is somehow completely different to what Github has for release 0.7.2, but in the NPM code lines 174-175 of j2c.commonjs.js are:

Assigning to rvalue sounds like it’s struggling with parsing an assignment operation as part of a greater operation. Sure enough, this works without a hitch:

…so there probably is a Browserify AST problem in there somewhere. However, bearing in mind using Git to search this repo for suffix doesn’t even yield any results, I tried mapping my dependency to the repo directly:

Читайте также:  Java error code 1 java install

And that works fine. In fact, even specifying the hash for the 0.7.2 release works fine.

So the fix would appear to be just to republish to NPM…

Источник

‘npm start’ fails with ‘SyntaxError: Assigning to rvalue’ #48

Comments

Hallo 👋 , I’m seeing the error SyntaxError: Assigning to rvalue when creating a new app with create-choo-app .

  • npx create-choo-app choo-example
  • cd choo-example
  • npm start

The text was updated successfully, but these errors were encountered:

A quick search suggests it could be an issue with the code being compiled somewhere, see vuejs/vue-template-es2015-compiler#8.

npm run build errors too, it looks like the same issue;

I tried replicating this on a different machine and I’m seeing what seems to be a similar issue but with different output.

I did notice that the version of choo installed is pretty outdated, here’s my package.json when running the same commands as in the original issue, this time on the following versions.

  • macOS El Capitan 10.11.3
  • node 9.2.0
  • npm 5.5.1
  • npx 9.6.0

I’m struggling to figure out why this’d be happening, would be interested to see if anyone else can replicate.

I think this might be because we do

without specifying version ranges for dependencies. So it installs the latest version that you have cached locally. If you do npm install choo@6 somewhere else and then run create-choo-app again, it will probably get the new version 🤔

It would be good if you would always get the newest version with create-choo-app, though! maybe we should drop the —cache-min part for now?

Thanks for the help @goto-bus-stop, that does look to be the issue.

Because I’ve previously installed versions of a lot of the dependencies it looks like a few of them were out of date, rather than updating each I ran npm cache clean —force .

It looks like this has caused issues previously and @yoshuawuyts suggested removing the —cache-min flag, I’m going to submit a PR to do that.

@chrisdwheatley PR merged! Hopefully that will resolve all issues going forward 😁

Источник

Оцените статью
toolgir.ru
Adblock
detector