Не удалось импортировать animejs

Я пытаюсь создать приложение Angular и хочу добавить анимацию, используя библиотеку animejs. Я добавил наборы animejs из DefinitlyTyped ( https://www.npmjs.com/package/@types/animejs) и импортировал их, используя import * as anime from 'animejs';,

Если я компилирую проект, используя ng serve, я получаю следующую ошибку:

ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'animejs' in '/Users/timon/Code/NodeFile/public/src/app'
resolve 'animejs' in '/Users/timon/Code/NodeFile/public/src/app'
  Parsed request is a module
  using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./src/app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./src/app)
    resolve as module
      /Users/timon/Code/NodeFile/public/src/app/node_modules doesn't exist or is not a directory
      /Users/timon/Code/NodeFile/public/src/node_modules doesn't exist or is not a directory
      /Users/timon/Code/node_modules doesn't exist or is not a directory
      /Users/timon/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Users/timon/Code/NodeFile/public/node_modules
        using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./node_modules)
          using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./node_modules/animejs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/node_modules/animejs doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/node_modules/animejs.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/node_modules/animejs.js doesn't exist
            as directory
              /Users/timon/Code/NodeFile/public/node_modules/animejs doesn't exist
      looking for modules in /Users/timon/Code/NodeFile/node_modules
        using description file: /Users/timon/Code/NodeFile/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/timon/Code/NodeFile/package.json (relative path: ./node_modules)
          using description file: /Users/timon/Code/NodeFile/package.json (relative path: ./node_modules/animejs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/node_modules/animejs doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/node_modules/animejs.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/node_modules/animejs.js doesn't exist
            as directory
              /Users/timon/Code/NodeFile/node_modules/animejs doesn't exist
      looking for modules in /Users/timon/Code/NodeFile/public/node_modules
        using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./node_modules)
          using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./node_modules/animejs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/node_modules/animejs doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/node_modules/animejs.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/node_modules/animejs.js doesn't exist
            as directory
              /Users/timon/Code/NodeFile/public/node_modules/animejs doesn't exist
      looking for modules in /Users/timon/Code/NodeFile/public/src
        using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./src)
          using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./src/animejs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/src/animejs doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/src/animejs.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/src/animejs.js doesn't exist
            as directory
              /Users/timon/Code/NodeFile/public/src/animejs doesn't exist
      looking for modules in /Users/timon/Code/NodeFile/public/src
        using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./src)
          using description file: /Users/timon/Code/NodeFile/public/package.json (relative path: ./src/animejs)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/src/animejs doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/src/animejs.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/timon/Code/NodeFile/public/src/animejs.js doesn't exist
            as directory
              /Users/timon/Code/NodeFile/public/src/animejs doesn't exist
[/Users/timon/Code/NodeFile/public/src/app/node_modules]
[/Users/timon/Code/NodeFile/public/src/node_modules]
[/Users/timon/Code/node_modules]
[/Users/timon/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/timon/Code/NodeFile/public/node_modules/animejs]
[/Users/timon/Code/NodeFile/node_modules/animejs]
[/Users/timon/Code/NodeFile/public/node_modules/animejs.ts]
[/Users/timon/Code/NodeFile/node_modules/animejs.ts]
[/Users/timon/Code/NodeFile/public/node_modules/animejs.js]
[/Users/timon/Code/NodeFile/node_modules/animejs.js]
[/Users/timon/Code/NodeFile/public/node_modules/animejs]
[/Users/timon/Code/NodeFile/node_modules/animejs]
[/Users/timon/Code/NodeFile/public/node_modules/animejs]
[/Users/timon/Code/NodeFile/public/node_modules/animejs.ts]
[/Users/timon/Code/NodeFile/public/node_modules/animejs.js]
[/Users/timon/Code/NodeFile/public/node_modules/animejs]
[/Users/timon/Code/NodeFile/public/src/animejs]
[/Users/timon/Code/NodeFile/public/src/animejs.ts]
[/Users/timon/Code/NodeFile/public/src/animejs.js]
[/Users/timon/Code/NodeFile/public/src/animejs]
[/Users/timon/Code/NodeFile/public/src/animejs]
[/Users/timon/Code/NodeFile/public/src/animejs.ts]
[/Users/timon/Code/NodeFile/public/src/animejs.js]
[/Users/timon/Code/NodeFile/public/src/animejs]
 @ ./src/app/app.component.ts 9:0-33
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Я сделал импорт JQuery таким же образом, и все работало нормально. IntelliJ также распознает модуль и предлагает завершение кода. @types/animejs доступен в node_modules.

Спасибо за вашу помощь!

0 ответов

Другие вопросы по тегам