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

postinstall is broken on Windows #118

Open
baltpeter opened this issue Jul 12, 2023 · 4 comments
Open

postinstall is broken on Windows #118

baltpeter opened this issue Jul 12, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@baltpeter
Copy link
Member

Error (this was when running npm i -g tweasel-cli):

npm ERR! code 1
npm ERR! path C:\Users\root\AppData\Roaming\npm\node_modules\tweasel-cli\node_modules\appstraction
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/postinstall.js; andromatic-install -p platform-tools 'build-tools;33.0.2'
npm ERR! node:internal/modules/cjs/loader:1078
npm ERR!   throw err;
npm ERR!   ^
npm ERR!
npm ERR! Error: Cannot find module 'C:\Users\root\AppData\Roaming\npm\node_modules\tweasel-cli\node_modules\appstraction\scripts\postinstall.js;'
npm ERR!     at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:920:27)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
npm ERR!     at node:internal/main/run_main_module:23:47 {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: []
npm ERR! }
npm ERR!
npm ERR! Node.js v18.15.0

Full debug log: 2023-07-12T21_42_03_073Z-debug-0.log

@baltpeter baltpeter added the bug Something isn't working label Jul 12, 2023
@baltpeter
Copy link
Member Author

As a workaround you can install like this: npm i appstraction --ignore-scripts.

This will skip the postinstall script and not preinstall the dependencies. But that isn't much of a problem. They are installed on demand anyway.

@zner0L
Copy link
Contributor

zner0L commented Jul 24, 2023

It seems like the error is caused by the semicolon being considered part of the path in Powershell. If I separate the semicolon from the path with a space, the postinstall script runs.

@zner0L
Copy link
Contributor

zner0L commented Aug 23, 2023

Aha, apparently npm on Windows doesn’t understand the semicolon at all and treats the second command as arguments of the first. Here is a minimal version to reproduce that:

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "postinstall": "echo 'first'; echo 'second'"
  }
}

On Windows 10 PowerShell, we get:

PS C:\Users\user\Documents\test> npm run postinstall

> test@1.0.0 postinstall
> echo 'first'; echo 'second'

'first'; echo 'second'

While on a Fedora zsh this runs like expected:

npm run postinstall

> [email protected] postinstall
> echo 'first'; echo 'second'

first
second

It should be noted that this is not an issue with PowerShell, as this runs it just fine:

PS C:\Users\user\Documents\test> echo 'first'; echo 'second'
first
second

The problem is that the normal Windows cmd does not recognize ; a a special character. Windows uses & for that. && should work on both machines, though, so maybe let’s use that.

@zner0L
Copy link
Contributor

zner0L commented Aug 25, 2023

The examples for Android seem to run fine on Windows, after I fixed the install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants