question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The token '||' is not a valid statement separator in this version.

See original GitHub issue
  • nodemon -v: Can’t install (i’m doing locally)
  • node -v: 12.10.0
  • Operating system/terminal environment: Window 10
  • Using Docker? What image: None
  • Command you ran: npm i nodemon --save-dev

Expected behaviour

Install correctly

Actual behaviour

node bin/postinstall || exit 0 `At line:1 char:22

  • node bin/postinstall || exit 0
  •                  ~~
    

The token ‘||’ is not a valid statement separator in this version. + CategoryInfo : ParserError: (😃 [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine`

Steps to reproduce

  • Create empty folder
  • Run npm init with all default value
  • Run npm i nodemon--save-dev

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
FieryRMScommented, Jul 18, 2021

Hi all, I managed to fix it sort of, run the following commands in order,

npm config set script-shell cmd

npm i nodemon

npm config set script-shell powershell

and for anyone trying to replicate the problem, run, npm config set script-shell powershell before npm i nodemon hope it help!

2reactions
Alchemiststcommented, Apr 8, 2020

I have been having this issue as well. I’m ussing powershell 6 (also tried with powershell 5.1 and got the same result).

As OP mentions, this is what I’ve done:

`
npm init
`
Everything goes all right. Then I execute:
`
npm install nodemon --save-dev
`
And the output I get is this:
`
> node bin/postinstall || exit 0

At line:1 char:22
+ node bin/postinstall || exit 0
+                      ~~
The token '||' is not a valid statement separator in this version.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidEndOfLine
 
npm WARN index.js@1.0.0 No description
npm WARN index.js@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodemon@2.0.2 postinstall: `node bin/postinstall || exit 0`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodemon@2.0.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Javi\AppData\Roaming\npm-cache\_logs\2020-02-09T13_01_40_897Z-debug.log

I have previously used nodemon (a month ago probably) in another project through this exact same install command and everything worked fine. Now, in that project, deleting the node_modules folder and running npm install yields the same output as above. It seems there’s something wrong with the command node bin/postinstall || exit 0 ‘||’ is not a powershell operator.

I’m glad to give any more details if needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The token '&&' is not a valid statement separator in this version
I found that within PowerShell as my terminal within VS Code , replacing && in the command with ; did the trick.
Read more >
The token '||' is not a valid statement separator in this version ...
nodemon isn't installing on my project. Operating system/terminal environment (powershell):; Versions: latest; Command you ran: npm install ...
Read more >
The token '&&' is not a valid statement separator in this version
The token '&&' is not a valid statement separator in this version | Visual Studio error. 8.5K views 1 year ago. Ajay Kumbhar....
Read more >
The token '&&' is not a valid statement separator in this version
Solution to fixing The Token '&&' is not a valid statement separator error seen in the Visual Studio Code terminal and Angular CLI....
Read more >
The token '&&' is not a valid statement separator in this version ...
[Solved]-The token '&&' is not a valid statement separator in this version-Reactjs · score:53. Accepted answer · score:2. I have solved the issue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found