我正在尝试使用Ionic和Cordova为Android构建这个项目,但我不知道为什么它抱怨NPM功能。
ionic-app-scripts build --target cordova --platform android
[INFO] Looks like @ionic/app-scripts isn't installed in this project.
This package is required for this command to work properly.
? Install @ionic/app-scripts? Yes
> npm i -D -E @ionic/app-scripts
Error: Failed to replace env in config: ${NPM_TOKEN}
at /usr/local/lib/node_modules/npm/lib/config/core.js:415:13
at String.replace (<anonymous>)
at envReplace (/usr/local/lib/node_modules/npm/lib/config/core.js:411:12)
at parseField (/usr/local/lib/node_modules/npm/lib/config/core.js:389:7)
at /usr/local/lib/node_modules/npm/lib/config/core.js:330:24
at Array.forEach (<anonymous>)
at Conf.add (/usr/local/lib/node_modules/npm/lib/config/core.js:328:23)
at ConfigChain.addString (/usr/local/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:316:10)
at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
/usr/local/lib/node_modules/npm/lib/npm.js:61
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (/usr/local/lib/node_modules/npm/lib/npm.js:61:13)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
at process.emit (events.js:182:13)
at process._fatalException (internal/bootstrap/node.js:485:27)
[ERROR] An error occurred while running subprocess npm.
npm i -D -E @ionic/app-scripts exited with exit code 7.
Re-running this command with the --verbose flag may provide more
information.
答案 0 :(得分:0)
先尝试rm -rf node_modules && npm install
,然后再尝试ionic build android
,看看是否有错误
答案 1 :(得分:0)
基本上需要更改npm令牌,并安装zsh才能更改令牌