从新拥有的TypeScript模块中找不到模块

我刚刚在NPM注册中心puppeteer-jquery上发布了一个新的Typescript项目。该代码工作正常。 但是当我尝试在其他项目中使用它时:

npm install puppeteer-jquery

,然后尝试使用以下命令导入它:

import { PageEx,BrowserEx } from 'puppeteer-jquery';

我得到了错误: Cannot find module 'puppeteer-jquery'.ts(2307)

在本地,我只能通过安装本地源副本并导入来使用它:

import { PageEx,BrowserEx } from './node_modules/puppeteer-jquery/src/setup';

来自pupeteer-jquery的package.json

{
  "name": "puppeteer-jquery",...
  "main": "lib/index.js",/* also tried with "./lib/index.js" value */
  "typings": "lib/index.d.ts",/* tried with "types" and "typings" key */
  "devDependencies": {
    ...
    "typescript": "^3.6.4"
  },"files": ["lib","data/*.js"] /* data contains jquery.js as a ressource */
}

来自puppeteer-jquery的tsconfig.json

{
  "compilerOptions": {
    "target": "ES2017","module": "commonjs","declaration": true,"strict": true,"moduleResolution": "node","esModuleInterop": true,"outDir": "lib","rootDirs": [
      "src"
    ]
  },"include": [ "src" ],/* added after the first post */
  "exclude": ["node_modules","lib"]
}

npm发布--dry-run:

npm notice ?  puppeteer-jquery@0.1.5
npm notice === Tarball Contents === 
npm notice 1.1kB   LICENSE              
npm notice 410B    lib/index.js         
npm notice 280.4kB data/jquery-3.4.1.js 
npm notice 5.7kB   lib/jQueryPlugin.js  
npm notice 77B     lib/PJQuery.js       
npm notice 1.0kB   lib/setup.js         
npm notice 1.2kB   package.json         
npm notice 2.0kB   README.md            
npm notice 242B    lib/index.d.ts       
npm notice 411B    lib/jQueryPlugin.d.ts
npm notice 2.2kB   lib/PJQuery.d.ts     
npm notice 518B    lib/setup.d.ts       
npm notice === Tarball Details === 

此问题看起来像stackoverflow 54695891,但不一样。

PS:

  • 这不是我的第一个Typescript项目
  • 这个项目没有依赖
  • 我还尝试将TS源和源映射包含到已发布的软件包中,但没有更多的成功。
bmlun 回答:从新拥有的TypeScript模块中找不到模块

我下载了该模块,看起来好像是您的构建或发布设置存在问题-<img src="../assets/myimg.png" id="myimg" v-bind:style="{ top: !ended ? '20%' : '80%'}"> 指向的文件lib/index.d.ts在发布的版本中不存在。

typings
本文链接:https://www.f2er.com/3161297.html

大家都在问