我已经使用yarn启动了一个打字稿项目,我运行了以下命令:
GridColumnMenuFilter
然后我创建了一个名为dev的脚本,该脚本运行yarn init -y
yarn add typescript -D
yarn tsc --init
yarn add ts-node-dev -D
,并且出现以下错误
tsnd src/index.ts
似乎yarn没有正确安装ts-node,因为每当我运行yarn run v1.22.4
$ tsnd src/index.ts
internal/modules/cjs/loader.js:329
throw err;
^
Error: Cannot find module 'D:\Documentos\Rafael\Rafael\Softwares\Typescript\base-typescript-project\node_modules\ts-node\dist\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:321:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:682:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:27)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (D:\Documentos\Rafael\Rafael\Softwares\Typescript\base-typescript-project\node_modules\ts-node-dev\lib\compiler.js:26:27)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32) {
code: 'MODULE_NOT_FOUND',
path: 'D:\\Documentos\\Rafael\\Rafael\\Softwares\\Typescript\\base-typescript-project\\node_modules\\ts-node\\package.json',
requestPath: 'ts-node'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS D:\Documentos\Rafael\Rafael\Softwares\Typescript\base-typescript-project>
然后运行npm i ts-node -D
时,它都能起作用,有人知道吗?
这是我的package.json:
yarn dev
答案 0 :(得分:1)
我猜我的毛线有问题,所以我运行yarn clean cache
并创建了一个新项目,现在它可以工作了。