我有两个使用npm的独立项目 - 所以我有两个:
some_base_folder/projectA/package.json
和some_base_folder/projectB/package.json
其中每个文件都有一个scripts
部分。
如果我转到some_base_folder/projectA/
并运行npm run-script test
,它会按照some_base_folder/projectA/package.json
的脚本部分执行测试命令。
我可以将"scripts": {test_projectA:'????'
作为some_base_folder/projectB/package.json
的价值放在some_base_folder/projectB/
中,以便当我在npm run-script test_projectA
并运行test
时,它将是
执行项目A的../projectA/npm run-script test
脚本?
我试过'..' is not recognized as an internal or external command,
operable program or batch file.
,但它说:
Disk /dev/sdb: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E434C200-63C3-4CB8-8097-DD369155D797
Device Start End Sectors Size Type
/dev/sdb1 2048 7814035455 7814033408 3.7T Linux RAID
Disk /dev/sdd: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: CAD9D9DA-1C3B-4FC2-95BD-A5F0B55DE313
Device Start End Sectors Size Type
/dev/sdd1 2048 7814035455 7814033408 3.7T Linux RAID
Disk /dev/sdc: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 090E94F6-A461-4B27-BCDF-5B49EC6AFC84
Device Start End Sectors Size Type
/dev/sdc1 2048 7814035455 7814033408 3.7T Linux RAID
Disk /dev/sde: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: A0285071-2C16-42B4-8567-32CE98147A93
Device Start End Sectors Size Type
/dev/sde1 2048 7814035455 7814033408 3.7T Linux RAID
Disk /dev/md0: 7.3 TiB, 8001301774336 bytes, 15627542528 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 524288 bytes / 1572864 bytes
我在Windows 7下运行,但更喜欢在Linux上运行正常的解决方案。
答案 0 :(得分:31)
"scripts": {
test_projectA:"cd ../projectA && npm run-script test"
}
答案 1 :(得分:3)
您应该使用--prefix
。
npm run some-command --prefix path/to/your/other/folder
答案 2 :(得分:1)
我最终使用:
"scripts": {
"job": "cd ./sub && \"$npm_execpath\" run subjob",
...
}
因为这也适用于纱线。