Cannot find module 'electron-publisher-custom', because the package name is already in use in npm
See original GitHub issue- Electron-Builder Version: 22.11.8
- Node Version: 15.3.0
- Electron Version: 13.1.6
- Electron Type (current, beta, nightly):
beta
- Target: win32
I am trying to use custom provider, the publish fails with the following warning:
⨯ Cannot find module 'electron-publisher-custom'
Require stack:
- D:\Code\ElectronDemo\node_modules\app-builder-lib\out\publish\PublishManager.js
- D:\Code\ElectronDemo\node_modules\app-builder-lib\out\index.js
- D:\Code\ElectronDemo\node_modules\electron-builder\out\builder.js
- D:\Code\ElectronDemo\node_modules\electron-builder\out\cli\cli.js
- D:\Code\ElectronDemo\node_modules\electron-builder\cli.js failedTask=build stackTrace=Error: Cannot find module 'electron-publisher-custom'
i think we should use providerName instead of name when constructing a new instance of a custom publisher,because the package name is already in use in npm,I don’t have permission to publish.
like this:
function requireProviderClass(provider: string, packager: Packager, customProviderName?:string): any | null {
switch (provider) {
case "github":
return GitHubPublisher
case "bintray":
return BintrayPublisher
case "generic":
return null
case "s3":
return S3Publisher
case "snapStore":
return SnapStorePublisher
case "spaces":
return SpacesPublisher
default: {
const name = `electron-publisher-${customProviderName}`
let module: any = null
try {
module = require(path.join(packager.buildResourcesDir, name + ".js"))
} catch (ignored) {
console.log(ignored)
}
if (module == null) {
module = require(name)
}
return module.default || module
}
}
}
or
function requireProviderClass(providerNmae: string, packager: Packager): any | null {
switch (providerNmae) {
case "GitHub":
return GitHubPublisher
...
default: {
const name = `electron-publisher-${providerNmae}`
let module: any = null
try {
module = require(path.join(packager.buildResourcesDir, name + ".js"))
} catch (ignored) {
console.log(ignored)
}
if (module == null) {
module = require(name)
}
return module.default || module
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
I'm getting the error because I'm trying to import the freeCodeCamp icon from the react-icons package, which I don't have installed. import { ......
Read more >package.json - npm Docs
Description. This document is all you need to know about what's required in your package.json file. It must be actual JSON, not just...
Read more >pkg - npm
This command line interface enables you to package your Node.js project into an executable that can be run even on devices without Node.js ......
Read more >Using npm packages in your projects
If you are creating a Node.js module, you can use a package in your module by passing it as an argument to the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If we use providerName instead of name,we can publish a custom package to npm, just use it this way, and we don’t need to store electron-publisher-custom.js files under folder resources.
eg:
electron-builder can’t find electron-publisher-custom.js files will execute the following code
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.