0

帮助我解决以下角度构建问题

ng build --configuration=qa


/opt/tomcat/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_14.15.0/lib/node_modules/@angular/cli/utilities/color.js:22
const colors = ansiColors.create();
                      ^

TypeError: ansiColors.create is not a function
    at Object.<anonymous> (/opt/tomcat/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_14.15.0/lib/node_modules/@angular/cli/utilities/color.js:22:27)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/opt/tomcat/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_14.15.0/lib/node_modules/@angular/cli/lib/init.js:15:17)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
4

2 回答 2

0

如果你调查./node_modules/@angular/cli/utilities/color.js你会发现这句话

 // Typings do not contain the function call (added in Node.js v9.9.0)

所以解决方案是至少要有一个v9.9.0的node.js版本

于 2021-05-27T12:10:34.057 回答
0

我今天遇到了这个问题,也使用了 Jenkins。我通过删除node_modules目录解决了它。

以前的脚本:

(cd client/ && npm install)
(cd client/ && npm run build)

新脚本:

(cd client/ && rm -r node_modules)
(cd client/ && npm install)
(cd client/ && npm run build)
于 2021-08-02T08:54:49.567 回答