hey*_*Joe 31 compilation node.js typescript tsconfig
我有打字稿编译的问题。smbd 遇到过吗?
node_modules/@types/node/index.d.ts(20,1): 错误 TS1084: 无效的“引用”指令语法。
tsconfig.json:
{
    "compileOnSave": false,
    "compilerOptions": {
        "sourceMap": true,
        "outDir": "./dist",
        "rootDir": "./app",
        "target": "es6",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "listFiles": false,
        "skipLibCheck": true
    },
    "include": [
        "./app/**/*.ts"
    ]
}
package.json 中的打字稿版本: "typescript": "^2.6.1"
小智 35
有同样的问题。打开文件 ../node_modules/@types/node/index.d.ts
并删除第三个斜线
// <reference lib="es2015" />
再次编译
小智 25
我得到了同样的错误。我在 package.json 中使用了固定版本 "@types/node": "7.0.7" 并使其正常工作。
sda*_*a87 12
我遇到了同样的问题,发现解决方案是将打字稿从当前版本更新到最新版本。
在 package.json 文件中进行如下更改:
"devDependencies": {
     "typescript": "^3.9.7"
 }
现在 "npm install typescript" ,它将升级到最新版本。然后运行“ng serve”,编译成功。
小智 5
它对我有用,可以检查 TypeScript 版本的标签。运行npm dist-tag ls @types/node并查找您当前的打字稿版本。
然后安装支持打字稿的@types/node 版本, 在我的情况下我必须安装 14.0.1 版本
参考:https : //github.com/DefinitelyTyped/DefinitelyTyped/issues/47250#issuecomment-687701880
小智 3
有同样的错误,修复方法是使用以前的版本,检查 package.json 中 @types/node 的版本,看看是否有最新版本。您可以在这里查看: https: //www.npmjs.com/package/@types/node,因为它表明有新的更新。
| 归档时间: | 
 | 
| 查看次数: | 25954 次 | 
| 最近记录: |