我想从nodemon开始我的项目
"scripts": {
"start": "tsc && node build/index.js",
"watch-server1": "nodemon --watch src/**/* -e ts,tsx --exec ts-node ./src/index.ts",
"watch-server2": "nodemon --watch 'src/**/*' -e ts,tsx --exec 'ts-node' ./src/index.ts"
},但是当我使用watch-server1时
(node:6830) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/leonsux/Desktop/Code/home/src/router/index.js:5
export default router;
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (internal/modules/cjs/loader.js:1167:16)
at Module._compile (internal/modules/cjs/loader.js:1215:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at main (/Users/leonsux/Desktop/Code/home/node_modules/ts-node/src/bin.ts:198:14)
at Object.<anonymous> (/Users/leonsux/Desktop/Code/home/node_modules/ts-node/src/bin.ts:288:3)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
[nodemon] app crashed - waiting for file changes before starting...当我使用watch-server2时,它工作得很好
那么,src/**/*和'src/**/*'有什么不同呢
发布于 2021-03-10 23:13:19
在将参数传递给nodemon之前,未加引号的shell字符(如* )将由shell展开。
用单引号将它们引起来可以防止外壳对它们进行扩展,因此将向nodemon传递文字字符串src/**/*作为参数。(它可以随心所欲地处理通配符--可能是扩展通配符本身。)
下面的例子说明了这一点有很大的不同:
scp 'remoteserver:*.txt' .对比:
scp remoteserver:*.txt .引用*允许scp打开到远程服务器的安全连接,并查看其中存在哪些文件。
如果您的本地shell对*进行了扩展,那么它只会在您的本地计算机上查找名称为"remoteserver:foo.txt“的文件,可能什么也找不到。
https://stackoverflow.com/questions/66567490
复制相似问题