【问题标题】:Package.json script cannot find newly created folder - Windows 10Package.json 脚本找不到新创建的文件夹 - Windows 10
【发布时间】:2020-12-20 08:13:42
【问题描述】:

在我的 Angular 应用程序中,我尝试创建一个 dist 文件夹,其中包含 scripts,而 index.html 放置在根文件夹中。这可以通过一些标志选项来实现。我尝试通过将其添加到我的 package.json 脚本中来自动执行此操作,但我的语法似乎不完整或错误。

脚本的前半部分工作正常,但第二部分却不行。当我单独执行move 脚本时,它工作正常。如何修复我的语法以便移动脚本也能运行?

当前脚本: "build:prod": "ng build --prod --output-path=\"dist/scripts\" --deployUrl=\"scripts/\" && move ./dist/scripts/index.html ./dist"

我的开发环境在 Windows 10

【问题讨论】:

  • 尝试mv 而不是move 并获得管理员权限
  • @Greedo 是对的,move 不是系统命令,如果是你在 package.json 中写的脚本你需要写成"build:prod": "ng build --prod --output-path=\"dist/scripts\" --deployUrl=\"scripts/\" && npm run move ./dist/scripts/index.html ./dist"
  • 感谢您的回复!抱歉,我忘了提到我在Windows....不确定mv 是否会这样工作?

标签: javascript angular package.json


【解决方案1】:

找到答案了!我没有正确地转义/。在完全工作的脚本下方。

"build:prod": "ng build --prod --output-path=\"dist/scripts\" --deployUrl=\"scripts/\" && mv ./dist/scripts/index.html || move .\\dist\\scripts\\index.html .\\dist\\"

【讨论】:

    猜你喜欢
    • 2015-11-15
    • 2016-12-09
    • 2013-09-01
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-22
    相关资源
    最近更新 更多