【发布时间】:2021-05-14 18:53:29
【问题描述】:
我似乎无法导入一个模块。
Typescript 2.7 节点 10
pxl-ng-security 在 VSCode 和 VS2019 中显示错误。如果我将鼠标悬停在它上面,它会显示错误 2307
这是文件的导入部分。
我的文件.ts
import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';
import { TokenService } from 'pxl-ng-security';
gulp 文件指向 tsconfig-library.json,所以我相信这意味着它使用该文件而不是标准的 tsconfig.json。
tsconfig-library.json
{
"compilerOptions": {
"target": "es5",
"lib": ["es2015", "dom"],
"module": "es2015",
"moduleResolution": "node",
"declaration": true,
"experimentalDecorators": true,
"baseUrl": ".",
"stripInternal": true,
"outDir": "./dist",
"rootDir": "./src-embedded",
"sourceMap": true,
"inlineSources": true,
"skipLibCheck": true
},
"files": [
"./src-embedded/index.ts"
],
"angularCompilerOptions": {
"skipTemplateCodeGen": true
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
]
}
}
我尝试过使用 ../../node_modules/pxl-ng-security,但它也有同样的问题。 Intellisense 看到并填写。我已经确认该文件夹确实在那个位置。我已经从 node_modules 中删除了它并执行了 npm-install -project-local 并且模块又回来了,所以看起来模块是健康且正确的。
运行 tsc -p 。给出以下错误
错误 TS2307:找不到模块 'pxl-ng-security' 或其 对应的类型声明。
如果我继续尝试运行 gulp,错误是“
错误:静态解析符号值时遇到错误。无法解析 pxl-ng-security
新细节。 我跳上 CI/CD 服务器,发现它运行良好。相同的代码正在处理它。我在上面安装了vscode,只是为了看看它是否显示相同的ts2307错误。很好。我检查了 Node 和 Typescript 的版本,它们都匹配。谜团还在继续
【问题讨论】:
-
问题/问题是什么?
-
我相信尽管正确安装了模块,你还是无法导入,对吧?尝试重新启动你的 ide?span>
-
抱歉这个糟糕的问题。我已经编辑过了。我还重新启动了我的 IDE 并使用了多个 IDE。
-
我没有在 npm 上看到那个包。
-
它是一个私有注册表
标签: angular typescript