【问题标题】:"Cannot find module 'three' from"“找不到模块‘三’来自”
【发布时间】:2018-03-29 01:01:49
【问题描述】:

我很难将我在 http://ssrb.github.io/mega-structure/mega-structure.html 的玩具打字稿应用程序从 typings 迁移到 @types/npm

我想不通的错误是Error: Cannot find module 'three'Error: Cannot find module 'codemirror'

工作流程是typescript/gulp/browserify

对于那次迁移,我删除了我的 typings.json 以及我的 gulpfilenpm install @types 中的所有打字内容。

然后我修复了一些由于升级类型定义后 API 更改而导致的错误。

我用一些import * as THREE from 'three';替换了///<reference path="typings/index.d.ts"/>

它现在无法捆绑,我试图弄清楚但没有成功:

[13:41:56] Using gulpfile mega-structure/gulpfile.js
[13:41:56] Starting 'default'...
[13:41:56] Starting '.bower.install'...
[13:41:58] Using cwd: mega-structure
[13:41:58] Using bower dir: ./bower_components
[13:42:01] Finished '.bower.install' after 4.99 s
[13:42:01] Starting '.peg'...
[13:42:01] Finished '.peg' after 131 ms
[13:42:01] Starting '.examples'...


[13:42:01] Finished '.examples' after 155 ms
[13:42:01] Starting '.ui.release'...
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Cannot find module 'three' from 'mega-structure'
    at mega-structure/node_modules/browser-resolve/node_modules/resolve/lib/async.js:46:17
    at process (mega-structure/node_modules/browser-resolve/node_modules/resolve/lib/async.js:173:43)
    at ondir (mega-structure/node_modules/browser-resolve/node_modules/resolve/lib/async.js:188:17)
    at load (mega-structure/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (mega-structure/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
    at mega-structure/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:152:21)

https://github.com/ssrb/mega-structure/commit/3285f5cb45c110d87ea5db795e47a4a392a15c1fhttps://travis-ci.org/ssrb/mega-structure/builds/359637820?utm_source=email&utm_medium=notification

【问题讨论】:

    标签: typescript gulp browserify


    【解决方案1】:

    问题在于构建使用three.jscodemirror、...的类型声明,使用npm 安装,但匹配的javascript 库仍使用bower 安装。 使用npm 而不是bower 安装库后,构建恢复了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-21
      • 2020-03-01
      • 1970-01-01
      • 2023-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-28
      相关资源
      最近更新 更多