mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Fix the issue of nodes not loading when run via npx (#5888)
This commit is contained in:
parent
2b9ca0d240
commit
e47190b560
|
@ -67,9 +67,19 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
|
||||||
this.downloadFolder = UserSettings.getUserN8nFolderDownloadedNodesPath();
|
this.downloadFolder = UserSettings.getUserN8nFolderDownloadedNodesPath();
|
||||||
|
|
||||||
// Load nodes from `n8n-nodes-base` and any other `n8n-nodes-*` package in the main `node_modules`
|
// Load nodes from `n8n-nodes-base` and any other `n8n-nodes-*` package in the main `node_modules`
|
||||||
await this.loadNodesFromNodeModules(CLI_DIR);
|
const pathsToScan = [
|
||||||
// Load nodes from installed community packages
|
// In case "n8n" package is in same node_modules folder.
|
||||||
await this.loadNodesFromNodeModules(this.downloadFolder);
|
path.join(CLI_DIR, '..'),
|
||||||
|
// In case "n8n" package is the root and the packages are
|
||||||
|
// in the "node_modules" folder underneath it.
|
||||||
|
path.join(CLI_DIR, 'node_modules'),
|
||||||
|
// Path where all community nodes are installed
|
||||||
|
path.join(this.downloadFolder, 'node_modules'),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const nodeModulesDir of pathsToScan) {
|
||||||
|
await this.loadNodesFromNodeModules(nodeModulesDir);
|
||||||
|
}
|
||||||
|
|
||||||
await this.loadNodesFromCustomDirectories();
|
await this.loadNodesFromCustomDirectories();
|
||||||
await this.postProcessLoaders();
|
await this.postProcessLoaders();
|
||||||
|
@ -117,8 +127,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
|
||||||
await writeStaticJSON('credentials', this.types.credentials);
|
await writeStaticJSON('credentials', this.types.credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async loadNodesFromNodeModules(scanDir: string): Promise<void> {
|
private async loadNodesFromNodeModules(nodeModulesDir: string): Promise<void> {
|
||||||
const nodeModulesDir = path.join(scanDir, 'node_modules');
|
|
||||||
const globOptions = { cwd: nodeModulesDir, onlyDirectories: true };
|
const globOptions = { cwd: nodeModulesDir, onlyDirectories: true };
|
||||||
const installedPackagePaths = [
|
const installedPackagePaths = [
|
||||||
...(await glob('n8n-nodes-*', { ...globOptions, deep: 1 })),
|
...(await glob('n8n-nodes-*', { ...globOptions, deep: 1 })),
|
||||||
|
|
Loading…
Reference in a new issue