如何解决Bitbucket 管道无法安装 angular cli?
我们有以下 Bitbucket 管道,可以在我们的 Bitbucket 分支上运行健全性检查
image: node:9.8.0
pipelines:
default:
- step:
script:
- cat /etc/apt/sources.list
- echo "deb http://ftp.ch.debian.org/debian/ jessie main contrib" > /etc/apt/sources.list
- echo "deb-src http://ftp.ch.debian.org/debian/ jessie main contrib" >> /etc/apt/sources.list
- echo "deb http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
- echo "deb-src http://security.debian.org/ jessie/updates main contrib" >> /etc/apt/sources.list
- cat /etc/apt/sources.list
- apt-get update -y && apt-get install -y gconf-service libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxss1 libxtst6 libappindicator1 libnss3 libasound2 libatk1.0-0 libc6 ca-certificates fonts-liberation lsb-release xdg-utils wget
- npm i npm@latest -g
- npm install -g --unsafe-perm @angular/cli@7.3.9
- cd /some_path
- npm install
- ng test --browsers=ChromeHeadlessNoSandbox --watch=false
- ng build --prod=true --configuration=sbox
失败
+ npm install -g --unsafe-perm @angular/cli@7.3.9
TypeError: Cannot destructure property `stat` of 'undefined' or 'null'.
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/node-gyp/lib/index.js:2:29)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/run-script-pkg.js:4:55)
at Module._compile (module.js:649:30)
/usr/local/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:163
throw new Error('call config.load() before reading values')
^
Error: call config.load() before reading values
at Config.get (/usr/local/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:163:13)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:171:32)
at process.emit (events.js:180:13)
at process._fatalException (bootstrap_node.js:431:27)
据说,这曾经有效,为什么现在坏了?
解决方法
旧版本的 node 不能总是运行最新的 npm。仅 npm 7.x guarantees support for node >= 10。
删除 npm i npm@latest -g
以使用 npm
的包分发版本或安装支持 node v9.x 的 npm 集版本。至少固定为主要版本 (npm i npm@^6
),但我更喜欢使用精确版本,因此构建更改在您的控制之下。
Nodes active LTS releases 和 list of released node/npm versions。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。