解决 Angular 官网下载的库 Schematics 在 windows 环境不支持 .. 的临时解决方案
我在 Angular 官網(wǎng)下載的 library Schematics 例子,運(yùn)行命令行 npm run build 時,遇到如下錯誤:
my-lib@0.0.1 build c:\Code\SPA\schematics-for-libraries\projects\my-lib
…/…/node_modules/.bin/tsc -p tsconfig.schematics.json
‘…’ is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-lib@0.0.1 build: ../../node_modules/.bin/tsc -p tsconfig.schematics.jsonnpm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-lib@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\I042416\AppData\Roaming\npm-cache_logs\2021-10-18T07_11_32_366Z-debug.log
問題的根源出現(xiàn)在 package.json 這一行:
“build”: “…/…/node_modules/.bin/tsc -p tsconfig.schematics.json”,
windows 不支持通過 …/…/ 去執(zhí)行當(dāng)前文件夾上級目錄里的某個可執(zhí)行文件。
調(diào)用的其實(shí)是這個 tsc 文件:
臨時解決方案
在庫的 package.json 里增添 TypeScript 的 devDependencies 依賴:
然后使用庫當(dāng)前目錄下的 node_modules 里的 tsc 進(jìn)行編譯:
最后問題解決,可以開始編譯了。
更多Jerry的原創(chuàng)文章,盡在:“汪子熙”:
總結(jié)
以上是生活随笔為你收集整理的解决 Angular 官网下载的库 Schematics 在 windows 环境不支持 .. 的临时解决方案的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 明日之后秋日森林boss刷新时间(网易《
- 下一篇: 解决 Angular 官网下载的库 Sc