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

Create .npmrc in dist/electron/UnPackaged even if the project doesn't have one #17504

Closed
yusufkandemir opened this issue Sep 11, 2024 · 2 comments
Assignees
Labels
bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. flavour/quasar-cli-vite flavour/quasar-cli-webpack kind/bug 🐞 mode/electron Qv2 🔝 Quasar v2 issues

Comments

@yusufkandemir
Copy link
Member

yusufkandemir commented Sep 11, 2024

We check if .npmrc exists before copying it here:

// handle .npmrc separately
const npmrc = this.ctx.appPaths.resolve.app('.npmrc')
if (fse.existsSync(npmrc)) {
let content = this.readFile(npmrc)
if (content.indexOf('shamefully-hoist') === -1) {
content += '\n# needed by pnpm\nshamefully-hoist=true'
}
// very important, otherwise PNPM creates symlinks which is NOT
// what we want for an Electron app that should run cross-platform
if (content.indexOf('node-linker') === -1) {
content += '\n# pnpm needs this otherwise it creates symlinks\nnode-linker=hoisted'
}
this.writeFile(
join(this.quasarConf.build.distDir, 'UnPackaged/.npmrc'),
content
)
}

If it doesn't exist, for example, when .npmrc is in the root folder in a monorepo, it won't be copied. So, pnpm would use symlinks and the build would fail on Windows, for example.
It won't be respected in monorepos without passing --ignore-workspace to unpackaged install params, but it's needed for that scenario, it's complex.

Solution
So, we should create a .npmrc file with the relevant options in dist/electron/UnPackaged even if the project doesn't have a .npmrc file.

Workaround
Create an empty .npmrc file in the project folder.

@yusufkandemir yusufkandemir self-assigned this Sep 11, 2024
@yusufkandemir yusufkandemir added kind/bug 🐞 mode/electron flavour/quasar-cli-webpack bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. flavour/quasar-cli-vite Qv2 🔝 Quasar v2 issues labels Sep 11, 2024
rstoenescu added a commit that referenced this issue Sep 16, 2024
rstoenescu added a commit that referenced this issue Sep 16, 2024
@rstoenescu
Copy link
Member

Will be available in q/app-vite 2.0.0-beta.22 & q/app-webpack 4.0.0-beta.23

@yusufkandemir
Copy link
Member Author

I was going to handle this one, but thanks 👍 I was going to update the matching to:

# ❌ don't match this, it's just mentioning the option in a comment:
# I am just mentioning node-linker here

# ❌ don't match this, it's commented out:
# node-linker=some-value

# ✅ match this
node-linker=hoisted

But, we even have to override the value as the user might need to use a specific node-linker option in their project. If we don't override it, the user will have a bad time as they will have to give up on something on their project, or it's just not going to work.

rstoenescu added a commit that referenced this issue Sep 19, 2024
…n/UnPackaged even if the project doesn't have one #17504
rstoenescu added a commit that referenced this issue Sep 19, 2024
…tron/UnPackaged even if the project doesn't have one #17504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed We have reproduce the problem and confirmed that this is a bug. flavour/quasar-cli-vite flavour/quasar-cli-webpack kind/bug 🐞 mode/electron Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

2 participants