Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mankinchi opened this issue Jan 19, 2020 · 15 comments
Closed

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

mankinchi opened this issue Jan 19, 2020 · 15 comments

Comments

@mankinchi
Copy link

  • 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
@stale
Copy link

stale bot commented Feb 2, 2020

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@stale stale bot added the stale no activity for 2 weeks label Feb 2, 2020
@remy
Copy link
Owner

remy commented Feb 2, 2020

Is this using powershell? (The issue does ask but it's not clear from your answer so hard to debug)

@stale stale bot removed the stale no activity for 2 weeks label Feb 2, 2020
@Alchemistst
Copy link

Alchemistst commented Feb 9, 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.

@stale
Copy link

stale bot commented Feb 23, 2020

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@stale stale bot added the stale no activity for 2 weeks label Feb 23, 2020
@stale stale bot closed this as completed Mar 1, 2020
@remy remy reopened this Mar 2, 2020
@stale stale bot removed the stale no activity for 2 weeks label Mar 2, 2020
@remy remy added the not-stale Tell stalebot to ignore this issue label Mar 2, 2020
@remy
Copy link
Owner

remy commented Mar 2, 2020

Needs to run on windows to investigate alternative fix.

@remy
Copy link
Owner

remy commented Apr 8, 2020

I can't replicate this at all. I've provisioned a Windows 10 machine from AWS and connect to it using Windows Remote Client, then go through the motion.

Attached is a screenshot of Powershell running the postinstall command, without error and I'm on a 5.x version of PS.

Screenshot 2020-04-08 at 20 42 18

If anyone is able to replicate this in a parred down example and able to offer a fix to the || statement, I'd love to hear about it.

I'll leave this open for the time being, but if it remains inactive, it'll close by itself (I hope that's fine).

@remy remy removed the not-stale Tell stalebot to ignore this issue label Apr 8, 2020
@ttomm
Copy link

ttomm commented Apr 11, 2020

I have the same problem.
I use Windows 10, I have Nodemon installed globally in version 2.0.3, but when I try to install Nodemon locally, in project folder, I get the same error

image

So I downloadad Nodemon from https://github.com/remy/nodemon as a zip file and unpacked next to my project folder , after that I removed || exit 0 from package.json and from my project folder I ran command

npm install ../nodemon-master

This not-very-elegant workaround works.

@remy
Copy link
Owner

remy commented Apr 11, 2020 via email

@Alchemistst
Copy link

I ended up switiching to Linux. Definitely not the best solution, but had the chance to do it and did it. Working seamlessly on Linux.

@stale
Copy link

stale bot commented Apr 30, 2020

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

@stale stale bot added the stale no activity for 2 weeks label Apr 30, 2020
@karanloona
Copy link

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.

Same error with me

@stale stale bot removed the stale no activity for 2 weeks label May 6, 2020
@remy
Copy link
Owner

remy commented May 6, 2020

I tried to replicate this and could not. And since no one was posting any pull requests to fix it, it'll close itself and won't be fixed.

I'm going to close this and encourage anyone who is able to replicate to offer a solution that allows the OR exit 0 to run cross platform. Thanks in advance.

@remy remy closed this as completed May 6, 2020
@FieryRMS
Copy link

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!

@ArmaanTechDeveloper
Copy link

  • 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

same error with me

@remy
Copy link
Owner

remy commented May 10, 2022

@ArmaanTechDeveloper did you try the fix (literally the last comment): npm config set script-shell powershell?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants