为什么需要concurrently 以及 npm run dev错误

来源:3-7 TypeScript的编译运转过程的进一步理解

慕莱坞0998854

2020-06-20

第一,我们为什么不直接写下面这样的script呢,为什么需要安装concurrently呢?(ps:我试着运行了下面的脚本,但是似乎tsc -w并没有watch相关ts的变化,我也不知道为什么)

"script":{
    "dev" : "tsc -w && nodemon node ./build/crowller.js"
 }

第二,按照老师的

  "dev":"concurrently npm:dev:*"

的方式,程序能正常运行,可是刚开始的时候会运行多次,怀疑是tsc 还没编译完成,就运行了node ./build/crowller.js,然后tsc编译完成了,又运行了node ./build/cowller.js

第三,按照老师在视频中弃用的写法

"dev":"concurrently npm run dev:build & npm run dev:start"

会报错:

 concurrently npm run dev:build & npm run dev:start

[1] 'run' �����ڲ����ⲿ���Ҳ���ǿ����еij���
[1] �����������
[2] �ļ�����Ŀ¼��������﷨����ȷ��
[1] run exited with code 1
[2] dev:build exited with code 1
[0] 
[0] Usage: npm <command>      
[0] 
[0] where <command> is one of:
[0]     access, adduser, audit, bin, bugs, c, cache, ci, cit,
[0]     clean-install, clean-install-test, completion, config,
[0]     create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
[0]     edit, explore, fund, get, help, help-search, hook, i, init,
[0]     install, install-ci-test, install-test, it, link, list, ln,
[0]     login, logout, ls, org, outdated, owner, pack, ping, prefix,
[0]     profile, prune, publish, rb, rebuild, repo, restart, root,
[0]     run, run-script, s, se, search, set, shrinkwrap, star,
[0]     stars, start, stop, t, team, test, token, tst, un,
[0]     uninstall, unpublish, unstar, up, update, v, version, view,
[0]     whoami
[0]
[0] npm <command> -h  quick help on <command>
[0] npm -l            display full usage info
[0] npm help <term>   search for help on <term>
[0] npm help npm      involved overview
[0]
[0] Specify configs in the ini-formatted file:
[0]     C:\Users\suxun\.npmrc
[0] or on the command line via: npm <command> --key value
[0] Config info can be viewed via: npm help config
[0]
[0] npm@6.13.4 C:\Program Files\nodejs\node_modules\npm
[0] npm exited with code 1

> relearn-ts@1.0.0 dev:start C:\Users\suxun\Desktop\RelearnTs
> nodemon node ./build/crowller.js

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node node ./build/crowller.js`



结果就是tsc并没有watch。真的好奇怪。

写回答

2回答

慕斯卡7269444

2021-09-19

第一次就会报错,因为 nondemon 找不到tsc编译后的产物。 先运行一次 npm run dev:build 即可

0
0

Dell

2020-08-05

我感觉是不是版本升级了

0
0

专为小白设计的TypeScript入门课

Dell老师专为TypeScript小白打造的,全栈式教学TS入门课程

2249 学习 · 506 问题

查看课程