You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SFDX授权Salesforce组织失败:模块导出语法错误

解决SFDX登录命令中的"Named export 'prompts' not found"错误

问题场景

执行SFDX组织登录命令:

sfdx org:login:web --alias testorg --instance-url https://test.salesforce.com --set-default

时触发语法错误,报错信息如下:

SyntaxError: Named export 'prompts' not found. The requested module '@salesforce/sf-plugins-core' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@salesforce/sf-plugins-core';
const { prompts } = pkg;

解决方案

1. 更新SFDX CLI到最新版本

这是最直接的修复方式,该问题多由旧版本CLI依赖的插件模块兼容性问题导致,官方新版本已修复导入逻辑。执行以下命令更新:

sfdx update

若通过npm安装CLI,也可使用:

npm install -g sfdx-cli

2. 手动修复模块导入(仅更新无效时尝试)

找到引用@salesforce/sf-plugins-core的代码文件,将原命名导入语句:

import { prompts } from '@salesforce/sf-plugins-core';

替换为默认导入后解构的方式:

import pkg from '@salesforce/sf-plugins-core';
const { prompts } = pkg;

注意:修改CLI核心依赖文件可能影响后续版本更新,优先推荐更新CLI方案。

3. 重新安装SFDX CLI

若更新无效,可尝试完全卸载后重新安装:

# 卸载CLI
npm uninstall -g sfdx-cli
# 重新安装最新版本
npm install -g sfdx-cli

内容的提问来源于stack exchange,提问作者user134185

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 16:57:05