Code Monkey home page Code Monkey logo

Comments (23)

ilyachalov avatar ilyachalov commented on May 27, 2024 1

@medikoo Thanks for the reply. I've already figured it out.

npm can be configured in command line:

> npm config set script-shell="pwsh"

And now I have succeeded (I also installed 'PowerShell 7'):

windows10-pwsh-ok

Thanks again. 🎉🎉🎉

from es5-ext.

medikoo avatar medikoo commented on May 27, 2024

@waiblinger thanks for the report, what terminal are you using on Windows? I was actually testing it on Windows prior release and all worked well.

from es5-ext.

waiblinger avatar waiblinger commented on May 27, 2024

I use the integrated terminal in Visual Studio Code (so cmd). The project ran yesterday befor the changes.

from es5-ext.

waiblinger avatar waiblinger commented on May 27, 2024

@medikoo I tried powershell as well. Same problem

from es5-ext.

ilyachalov avatar ilyachalov commented on May 27, 2024

@medikoo I'm trying to install 'gulp-cli' from 'npm' and I have the same problem (Windows 10):

windows10-powershell

|| is pipeline chain operator. They appeared in 'PowerShell 7':

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pipeline_chain_operators

'Windows Powershell' (version 5.1) comes with 'Windows 10', executable file 'powershell.exe'.
'Powershell 7' can be obtained separately, executable file 'pwsh.exe'.
'Windows Powershell' (version 5.1) and 'Powershell 7' installed side by side.

'Windows Powershell' (version 5.1) does not have an pipeline chain operator ||.

I think the line
powershell -c node -e "try{require('./_postinstall')}catch(e){}" || exit 0
need to replace with
pwsh -c node -e "try{require('./_postinstall')}catch(e){}" || exit 0

Then it will work for those who have installed 'PowerShell 7'.

from es5-ext.

medikoo avatar medikoo commented on May 27, 2024

I think the line
powershell -c node -e "try{require('./_postinstall')}catch(e){}" || exit 0
need to replace with
pwsh -c node -e "try{require('./_postinstall')}catch(e){}" || exit 0

It's actually an npm that adds powershell -c, so it'll be good to confirm if that happens with latest npm version, and eventually report issue over there.

from es5-ext.

mrJli avatar mrJli commented on May 27, 2024

Windows 11, PowerShell 7.2.6, i try this npm config set script-shell="pwsh" but
изображение

from es5-ext.

ilyachalov avatar ilyachalov commented on May 27, 2024

@mrJli Are you really running the installation in PowerShell? PowerShell command prompt usually looks like this PS C:\>. You have the command prompt shown as $. Perhaps you are using 'Git Bash' (or some other shell) rather than 'PowerShell'?

Can you show a screenshot without cropping the window title?

from es5-ext.

mrJli avatar mrJli commented on May 27, 2024

@mrJli Are you really running the installation in PowerShell? PowerShell command prompt usually looks like this PS C:\>. You have the command prompt shown as $. Perhaps you are using 'Git Bash' (or some other shell) rather than 'PowerShell'?

Can you show a screenshot without cropping the window title?

изображение

from es5-ext.

ilyachalov avatar ilyachalov commented on May 27, 2024

@mrJli Earlier it was about a mistake with operator ||. To fix this error I used 'PowerShell 7' and 'npm' setting npm config set script-shell="pwsh".

You have a different situation. You have a unary operator --, which is not needed there:

pwsh -c --  node -e "try{require('./_postinstall')}catch(e){}" || exit 0

'es5-ext' is responsible for part of the command:
https://github.com/medikoo/es5-ext/blob/main/package.json

 node -e "try{require('./_postinstall')}catch(e){}" || exit 0

I think 'npm' is responsible for the initial part:

pwsh -c -- 

Maybe it's a bug in npm:
npm/cli#5332

What version of 'npm' do you have (npm --version, I have 8.12.1)? Maybe you should use a different version of 'npm'.

from es5-ext.

mrJli avatar mrJli commented on May 27, 2024

npm version - 8.19.2
i try to install 8.12.1 and all works, thanks

from es5-ext.

rjwut-chg avatar rjwut-chg commented on May 27, 2024

I have zero issue with the message and intent behind the postinstall script, but perhaps unintended consequences like this are a good argument for limiting that sort of thing to the README.md file instead.

from es5-ext.

kieselai avatar kieselai commented on May 27, 2024

This was quite frustrating to figure out, since I was calling my script from PowerShell core, but this postinstall script was still being called from PowerShell 5. I haven't had issues on any other machine I've ran it on, but this one apparently didn't have pwsh configured as the "script-shell".
Results on Google simply suggested using the compatible syntax for PowerShell 5, which isn't helpful when it's not a script I'm executing directly.
It wasn't until going directly to this repo and looking at the open issues that I saw what the solution was. It's obvious in hindsight, but was a bit of a runaround getting here.
I know cross compatibility with windows is a pain, but this is the first package I've ran into this particular issue.

If it helps, here are the versions of software/libs I'm running:
PowerShell: 7.3.4
Node: v18.15.0
pnpm: 8.6.3
npm: 9.4.0

And the solution for me was to set pwsh as the script-shell:
npm config set script-shell="pwsh"

from es5-ext.

kieselai avatar kieselai commented on May 27, 2024

The more I look into it, I think the specific problem might occur if PowerShell 5 (or earlier) was previously specified as the script-shell. cmd.exe actually does allow "||" and "&&" operators, so I think the problem is specifically with older versions of PowerShell being the default script-shell.

from es5-ext.

kieselai avatar kieselai commented on May 27, 2024

It would have been PowerShell 6 and earlier with the problem, my mistake

from es5-ext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.