关键词搜索

源码搜索 ×
×

解决 Angular 官网下载的库 Schematics 在 windows 环境不支持 .. 的临时解决方案

发布2021-10-18浏览539次

详情内容

我在 Angular 官网下载的 library Schematics 例子,运行命令行 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

问题的根源出现在 package.json 这一行:

“build”: “…/…/node_modules/.bin/tsc -p tsconfig.schematics.json”,

windows 不支持通过 …/…/ 去执行当前文件夹上级目录里的某个可执行文件。

调用的其实是这个 tsc 文件:

临时解决方案

在库的 package.json 里增添 TypeScript 的 devDependencies 依赖:

然后使用库当前目录下的 node_modules 里的 tsc 进行编译:

最后问题解决,可以开始编译了。

更多Jerry的原创文章,尽在:“汪子熙”:

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载