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

@nestjs/core post install script fails on powershell #7049

Closed
IamKayrox opened this issue May 6, 2021 · 5 comments
Closed

@nestjs/core post install script fails on powershell #7049

IamKayrox opened this issue May 6, 2021 · 5 comments
Labels
needs triage This issue has not been looked into

Comments

@IamKayrox
Copy link

IamKayrox commented May 6, 2021

Bug Report

When running npm install on an already existing project I get this error

> opencollective || exit 0

At line:1 char:16
+ opencollective || exit 0
+                ~~
The token '||' is not a valid statement separator in this version.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidEndOfLine

When I try creating a new project with the CLI the installation fails

Current behavior

Installation and setup fails, the project won't run.
Postinstall script seems to fail when running on PowerShell

Expected behavior

Installation not failing

Environment

  • Nest version: 7.1.3 | 7.2.0 | 7.6.15
  • Node version: 12.16.0
  • Platform Windows 10 64bits

Others:
I had set up NPM too run scripts on PowerShell

@IamKayrox IamKayrox added the needs triage This issue has not been looked into label May 6, 2021
@IamKayrox
Copy link
Author

Also, if I set npm script-shell config to cmd the post install script fails too. I managed to install this by deleting the script-shell config on npm

@micalevisk
Copy link
Member

I think you could run npm install --ignore-scripts to bypass this

https://docs.npmjs.com/cli/v7/commands/npm-install#ignore-scripts

@IamKayrox
Copy link
Author

I think you could run npm install --ignore-scripts to bypass this

https://docs.npmjs.com/cli/v7/commands/npm-install#ignore-scripts

I tried this, for some reason is like the installations ends up being incomplete and it won't work after that.

@hedgerh
Copy link

hedgerh commented Aug 12, 2021

So it looks like the issue is that in previous nestjs versions, the postinstall script to run the opencollective log thing after install looked like

"postinstall": "opencollective || exit 0"

Which is part of the @nuxtjs/opencollective package's setup instructions https://www.npmjs.com/package/@nuxtjs/opencollective#setup

It looks like the latest version of @nestjs/core got rid of the || exit 0: https://github.com/nestjs/nest/blob/master/package.json#L26

The issue is that || isn't a valid operator in powershell. It'd look like opencollective -or exit 0 or something instead.

I'm not sure how you are gonna be able to install these v7 versions of nestjs using powershell unless you can someone stop that @nestjs/core postinstall specifically from running or throwing an error. My guess is that when you run npm install --ignore-scripts, you are stopping the postinstalls of other dependencies from running, hence the incomplete install. It doesn't appear that @nestjs/core has any preinstall, and the postinstall just outputs a message to the terminal, so ignoring that specific postinstall script shouldn't break anything.

You may want to consider using git bash or something to install on Windows instead as a last resort. Otherwise, you should try out the latest nestjs core and see if it breaks. Those sound better than forking your current nestjs/core version or something to get rid of that || exit 0.

@kamilmysliwiec
Copy link
Member

Let's track this here nuxt-contrib/opencollective#68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

4 participants