Skip to content

Commit 55c066a

Browse files
fix(installer): add absolute path resolution for Pro module in npx context (#508)
When running via `npx aios-core install`, require() resolves from the npx temp directory, not process.cwd(). After bootstrap installs @aios-fullstack/pro in the user's project, the existing 3 resolution paths all fail. Add 4th path using absolute path to process.cwd()/node_modules/@aios-fullstack/pro/license/ which is where the bootstrap actually installs the package. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8530ffe commit 55c066a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

packages/installer/src/wizard/pro-setup.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,28 +152,42 @@ function showStep(current, total, label) {
152152
* 1. Relative path (framework-dev mode: ../../../../pro/license/{name})
153153
* 2. @aios-fullstack/pro package (brownfield: node_modules/@aios-fullstack/pro/license/{name})
154154
* 3. Absolute path via aios-core in node_modules (brownfield upgrade)
155+
* 4. Absolute path via @aios-fullstack/pro in user project (npx context)
156+
*
157+
* Path 4 is critical for npx execution: when running `npx aios-core install`,
158+
* require() resolves from the npx temp directory, not process.cwd(). After
159+
* bootstrap installs @aios-fullstack/pro in the user's project, only an
160+
* absolute path to process.cwd()/node_modules/@aios-fullstack/pro/... works.
155161
*
156162
* @param {string} moduleName - Module filename without extension (e.g., 'license-api')
157163
* @returns {Object|null} Loaded module or null
158164
*/
159165
function loadProModule(moduleName) {
166+
const path = require('path');
167+
160168
// 1. Framework-dev mode (cloned repo with pro/ submodule)
161169
try {
162170
return require(`../../../../pro/license/${moduleName}`);
163171
} catch { /* not available */ }
164172

165-
// 2. @aios-fullstack/pro installed in user project
173+
// 2. @aios-fullstack/pro package (works when aios-core is a local dependency)
166174
try {
167175
return require(`@aios-fullstack/pro/license/${moduleName}`);
168176
} catch { /* not available */ }
169177

170178
// 3. aios-core in node_modules (brownfield upgrade from >= v4.2.15)
171179
try {
172-
const path = require('path');
173180
const absPath = path.join(process.cwd(), 'node_modules', 'aios-core', 'pro', 'license', moduleName);
174181
return require(absPath);
175182
} catch { /* not available */ }
176183

184+
// 4. @aios-fullstack/pro in user project (npx context — require resolves from
185+
// temp dir, so we need absolute path to where bootstrap installed the package)
186+
try {
187+
const absPath = path.join(process.cwd(), 'node_modules', '@aios-fullstack', 'pro', 'license', moduleName);
188+
return require(absPath);
189+
} catch { /* not available */ }
190+
177191
return null;
178192
}
179193

0 commit comments

Comments
 (0)