【问题标题】:cannot find module 'pouchdb', works on mac, but not on windows找不到模块'pouchdb',适用于mac,但不适用于windows
【发布时间】:2019-01-07 09:17:52
【问题描述】:

我正在接管一个适用于我的 mates mac 的 ionic 项目。清洁安装了 ionic/cordova/python 的 windows 10 PC。项目运行,但出现以下错误。我尝试了多种在项目中包含 pouchdb 的不同方法(使用 @types/ 使用旧版本,使用 require 而不是导入、删除和重新安装节点模块等),但我找不到任何解决此错误的方法。我已经恢复了我所做的所有更改。以下代码适用于我的 mates mac。

我也刚刚与他核实了版本。我正在运行所有相同版本的 node/python/ionic 等。

package.json

{
    "name": "camara2",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "5.0.0",
        "@angular/compiler": "5.0.0",
        "@angular/compiler-cli": "5.0.0",
        "@angular/core": "5.0.0",
        "@angular/forms": "5.0.0",
        "@angular/http": "5.0.0",
        "@angular/platform-browser": "5.0.0",
        "@angular/platform-browser-dynamic": "5.0.0",
        "@ionic-native/camera": "^4.11.0",
        "@ionic-native/core": "4.3.2",
        "@ionic-native/splash-screen": "4.3.2",
        "@ionic-native/status-bar": "4.3.2",
        "@ionic/storage": "2.1.3",
        "@types/pouchdb": "6.3.2",
        "ajv": "^6.0.0",
        "cordova-android": "^6.2.3",
        "cordova-browser": "^4.1.0",
        "cordova-ios": "^4.4.0",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-compat": "^1.2.0",
        "cordova-plugin-console": "^1.1.0",
        "cordova-plugin-device": "^1.1.7",
        "cordova-plugin-splashscreen": "^4.1.0",
        "cordova-plugin-statusbar": "^2.4.2",
        "cordova-plugin-whitelist": "^1.3.3",
        "cropperjs": "^1.4.1",
        "ionic": "^4.6.0",
        "ionic-angular": "3.9.2",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "json-circular-stringify": "0.0.1",
        "mrz": "^3.1.0",
        "newtondev-mrz-parser": "^1.1.0",
        "rxjs": "5.5.2",
        "sw-toolbox": "3.6.0",
        "tesseract.js": "^1.0.10",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@ionic/app-scripts": "3.2.1",
        "@ionic/lab": "1.0.6",
        "typescript": "2.4.2"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-camera": {},
            "cordova-plugin-console": {}
        },
        "platforms": [
            "android",
            "browser",
            "ios"
        ]
    }
}

导入

//import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Http, Headers, HttpModule } from '@angular/http';
import PouchDB from 'pouchdb';
import 'rxjs/add/operator/map';

【问题讨论】:

  • 您是否尝试将 pouchdb 添加到您的依赖项中?
  • 那里有"@types/pouchdb": "6.3.2",。我也尝试使用不带@types 的依赖项,它也不起作用。
  • "@types/pouchdb": "6.3.2" 不是模块。这只是打字稿的打字。 “这个包包含 pouchdb 的类型定义”npmjs.com/package/@types/pouchdb
  • 他的node_modules 中有目录pouchdb,你有这个目录吗?他是否在他的 tsconfig.js 中配置了路径,你有吗?

标签: javascript angular ionic-framework ionic3


【解决方案1】:

你必须安装 PouchDB

npm install --save pouchdb

@types/pouchdb 不是实际的模块。这只是打字稿的打字。你需要两个模块。

【讨论】:

  • 你应该安装 pouchdb 和 @types/pouchdb
  • 你好像只安装了@types/pouchdb - 做npm install pouchdb @types/pouchdb
猜你喜欢
  • 2012-02-08
  • 1970-01-01
  • 2016-11-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多