[英]nodemon is unable to find ts-node in exec-parameter
I'm trying to use ts-node with nodemon.我正在尝试将 ts-node 与 nodemon 一起使用。 Both are installed using yarn and my package.json has the following structure:两者都是使用 yarn 安装的,我的 package.json 具有以下结构:
{
"name": "yarnTest",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@types/express": "^4.0.36",
"bootstrap-sass": "^3.3.7",
"nodemon": "^1.11.0",
"typescript": "^2.4.1"
},
"dependencies": {
"@types/chalk": "^0.4.31",
"chalk": "^2.0.1",
"express": "^4.15.3",
"ts-node": "^3.2.0"
},
"scripts": {
"dev": "nodemon --exec 'ts-node --cache-directory .tscache' ./src/www.ts",
"start": "ts-node --fast ./dist/www.ts"
}
}
Now, when I use "yarn run dev", it executes nodemon and nodemon tries to execute "ts-node" but nodemon tells me that the command "ts-node" does not exist:现在,当我使用“yarn run dev”时,它会执行 nodemon,nodemon 会尝试执行“ts-node”,但 nodemon 告诉我命令“ts-node”不存在:
Der Befehl "'ts-node" ist entweder falsch geschrieben oder konnte nicht gefunden werden. Der Befehl "'ts-node" ist entweder falsch geschrieben oder konnte nicht gefunden werden。
Yarn is installed globally but ts-node is installed for my project only. Yarn 是全局安装的,但 ts-node 仅为我的项目安装。 I already tried:我已经尝试过:
"scripts": {
"dev": "nodemon --exec 'yarn run ts-node --cache-directory .tscache' ./src/www.ts",
"start": "ts-node --fast ./dist/www.ts"
}
But this gives me the error that "yarn" is not found:( Any ideas how to fix this issue?但这给了我找不到“纱线”的错误:(有什么办法可以解决这个问题吗?
You should install ts-node
first, run npm install -g ts-node
你应该先安装ts-node
,运行npm install -g ts-node
I finally solved the issue, After some hours I figured out that nodemon told me.我终于解决了这个问题,几个小时后我想通了 nodemon 告诉我的。 that it's unable to find "'ts-node" (or "'yarn"), The apostroph was confusing me.它无法找到“'ts-node”(或“'yarn”),撇号让我感到困惑。 so I finally replaced both apostrophes in my package:json with " and now my working script command is the following one:所以我最终用 " 替换了 package:json 中的两个撇号,现在我的工作脚本命令如下:
"dev": "nodemon --exec \"ts-node --cache-directory .tscache\" ./src/www.ts"
我只是在我的小型打字稿项目(约500个.ts文件)中使用tsmon
https://www.npmjs.com/package/tsmon
tsmon ./src/www.ts
2020 Update 2020年更新
I am trying to run a typescript file with nodemon and following dev
script in package.json is sufficient我正在尝试使用 nodemon 运行打字稿文件,并在 package.json 中遵循dev
脚本就足够了
{
"dev": "nodemon src/index.ts"
}
No need of including ts-node in the dev script.无需在开发脚本中包含 ts-node。
I have ts-node and nodemon in dependencies我在依赖项中有 ts-node 和 nodemon
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.