自己安装命令安装之后,在ts.config.json里面配置之后(最后一行)
{ "compilerOptions": { "target": "es5", "module": "esnext", "strict": true, "jsx": "preserve", "importHelpers": true, "moduleResolution": "node", "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "useDefineForClassFields": true, "sourceMap": true, "baseUrl": ".", "types": [ "webpack-env", // "node" ], "paths": { "@/*": [ "src/*" ] }, "lib": [ "esnext", "dom", "dom.iterable", "scripthost" ] }, "include": [ "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx" ], "exclude": [ "node_modules" ], "references": [{ "path": "./tsconfig.node.json" }], "type":["node"] }
刚开始没有配置references,配置type仍然报错,后来看一篇文章对比作者的ts.config.json.发现没有references,添加之后就不报错了,后来volar蹦了一次,我将type&references注掉之后,require居然也不报错了。。。
记录一下~
标签:node,src,require,ts,报错,references,true From: https://www.cnblogs.com/guohuimin/p/16635556.html