Не удается разрешить зависимость в nodemodule - PullRequest
0 голосов
/ 07 апреля 2020

для проекта нам нужно использовать частное репо в качестве зависимости, как только я установил его с npm и попытался импортировать один из классов в частном репо, я получил, что не могу разрешить зависимость. проект использует parcel. Я вызываю следующий код в app.ts

import Input from "dgs/src/ts/core/components/input/Input";

let input = Input.keyboard.getKeys();
console.log(input);

и затем: npm run dev, что приводит к:

x C:\Users\ricardo\Desktop\testInputs\node_modules\dgs\src\ts\core\components\input\gesture_detection.ts:6:26: Cannot resolve dependency '~ts/utility/math_extended/vector2' at 'C:\Users\ricardo\Desktop\testInputs\node_modules\dgs\src\ts\core\components\input\~ts\utility\math_extended\vector2'
    at Resolver.resolve (C:\Users\ricardo\Desktop\testInputs\node_modules\parcel\src\Resolver.js:71:17)
    at async Bundler.resolveAsset (C:\Users\ricardo\Desktop\testInputs\node_modules\parcel\src\Bundler.js:433:18)
    at async Bundler.resolveDep (C:\Users\ricardo\Desktop\testInputs\node_modules\parcel\src\Bundler.js:484:14)
    at async C:\Users\ricardo\Desktop\testInputs\node_modules\parcel\src\Bundler.js:608:26
    at async Promise.all (index 4)
    at async Bundler.loadAsset (C:\Users\ricardo\Desktop\testInputs\node_modules\parcel\src\Bundler.js:599:21)
    at async Bundler.processAsset (C:\Users\ricardo\Desktop\testInputs\node_modules\parcel\src\Bundler.js:557:5)
    at async PromiseQueue._runJob (C:\Users\ricardo\Desktop\testInputs\node_modules\parcel\src\utils\PromiseQueue.js:48:7) 

package. json:

  "name": "testinputs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "clean": "rimraf ./dist ./.cache",
    "dev": "parcel ./src/index.html --open",
    "build": "npm run clean && parcel build ./src/index.html --no-source-maps --public-url ./"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@types/lodash": "^4.14.149",
    "dgs": "git+ssh://git@bitbucket.org/BrandedGame/brandedgames_game_engine.git#ricardoduinkerken",
    "linq-collections": "^1.0.254",
    "lodash": "^4.17.15",
    "pixi": "^0.3.1",
    "strongly-typed-events": "^1.6.8",
    "ts-keycode-enum": "^1.0.6"
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/preset-env": "^7.8.4",
    "@types/jasmine": "3.3.0",
    "@types/jest": "^25.1.2",
    "@types/node": "^13.7.0",
    "babel-core": "^6.0.20",
    "babel-jest": "^25.1.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.0.15",
    "gulp-sass": "^4.0.2",
    "http-server": "^0.12.1",
    "jasmine": "3.3.0",
    "jest": "^25.1.0",
    "jest-extended": "^0.11.5",
    "js-mobile-console": "^0.4.0",
    "karma": "^4.4.1",
    "karma-chrome-launcher": "2.2.0",
    "karma-jasmine": "2.0.1",
    "karma-typescript": "^4.1.1",
    "karma-typescript-es6-transform": "^4.1.1",
    "parcel": "^1.12.4",
    "parcel-bundler": "^1.12.4",
    "rimraf": "^2.7.1",
    "ts-jest": "^25.2.0",
    "typescript": "^2.9.2"
  }
}

ts config:

{
    "compilerOptions": {
      /* Basic Options */
      "target": "ES6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
      "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
      "lib": [
        "DOM",
        "ES2018"
      ] /* Specify library files to be included in the compilation. */,
      "allowJs": false /* Allow javascript files to be compiled. */,
      "checkJs": false /* Report errors in .js files. */,
      "sourceMap": true /* Generates corresponding '.map' file. */,
      "removeComments": true /* Do not emit comments to output. */,
      "noEmit": false /* Do not emit outputs. */,
      "declaration": true,
      "baseUrl": "./src",
      "paths": {
        "~*": [
          "./*"
        ]
      },
      /* Strict Type-Checking Options */
      "strict": true /* Enable all strict type-checking options. */,
      "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
      "strictNullChecks": true /* Enable strict null checks. */,
      "strictFunctionTypes": true /* Enable strict checking of function types. */,
      //"strictBindCallApply": false /* Enable strict 'bind', 'call', and 'apply' methods on functions. */,
      "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */,
      "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
      "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
      /* Additional Checks */
      "noUnusedLocals": true /* Report errors on unused locals. */,
      "noUnusedParameters": true /* Report errors on unused parameters. */,
      "noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
      "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
      /* Module Resolution Options */
      "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
      "typeRoots": [
        "node_modules/@types"
      ] /* List of folders to include type definitions from. */,
      "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
      "forceConsistentCasingInFileNames": false /* Disallow inconsistently-cased references to the same file. */,
      "experimentalDecorators": true
    },
    "include": [
      "./"
    ]
  }
...