Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第一次npm run dev:rn 编译时:Cannot find module 'fbjs/lib/keyMirror' #2121

Closed
harry7988 opened this issue Feb 9, 2019 · 11 comments
Closed
Assignees

Comments

@harry7988
Copy link

问题描述
第一次npm run dev:rn 编译时:Cannot find module 'fbjs/lib/keyMirror'

复现步骤
[复现问题的步骤]

  1. npm install -g @tarojs/cli
  2. taro init myApp
  3. npm run dev:rn
HarrydeMacBook:~ harry$ npm install -g @tarojs/cli
npm WARN deprecated babel-plugin-remove-dead-code@1.3.2: use babel-plugin-minify-dead-code-elimination and babel-plugin-minify-guarded-expressions
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
/Users/harry/.nvm/versions/node/v8.15.0/bin/taro -> /Users/harry/.nvm/versions/node/v8.15.0/lib/node_modules/@tarojs/cli/bin/taro

> fsevents@1.2.7 install /Users/harry/.nvm/versions/node/v8.15.0/lib/node_modules/@tarojs/cli/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download 
[fsevents] Success: "/Users/harry/.nvm/versions/node/v8.15.0/lib/node_modules/@tarojs/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" is installed via remote
npm WARN eslint-plugin-taro@1.2.12 requires a peer of babel-eslint@^8.2.3 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-taro@1.2.12 requires a peer of eslint@^4.15.0 but none is installed. You must install peer dependencies yourself.

+ @tarojs/cli@1.2.12
added 607 packages from 458 contributors in 6.482s

HarrydeMacBook:~ harry$ cd Desktop/
HarrydeMacBook:Desktop harry$ taro init myAPP
👽 Taro v1.2.12

Taro即将创建一个新项目!
Need help? Go and open issue: https://github.com/NervJS/taro/issues/new

? 请输入项目介绍! myAPP
? 是否需要使用 TypeScript ? No
? 请选择 CSS 预处理器(Sass/Less/Stylus) Less
? 请选择模板 默认模板

✔ 创建项目: myAPP
✔ 创建配置目录: myAPP/config
✔ 创建源码目录: myAPP/src
✔ 创建页面目录: myAPP/src/pages
✔ 创建页面 JS 文件: myAPP/src/pages/index/index.js
✔ 创建页面 LESS 文件: myAPP/src/pages/index/index.less
✔ 创建文件: myAPP/src/app.js
✔ 创建文件: myAPP/src/app.less
✔ 创建文件: myAPP/src/index.html
✔ 创建文件: myAPP/config/index.js
✔ 创建文件: myAPP/config/dev.js
✔ 创建文件: myAPP/config/prod.js
✔ 创建文件: myAPP/.editorconfig
✔ 创建文件: myAPP/.gitignore
✔ 创建文件: myAPP/package.json
✔ 创建文件: myAPP/.eslintrc
✔ 创建文件: myAPP/project.config.json

✔ Initialized empty Git repository in /Users/harry/Desktop/myAPP/.git/

✔ 安装成功
warning @tarojs/webpack-runner > webpack-format-messages > kleur@2.0.2: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
warning @tarojs/webpack-runner > node-sass > request > hawk > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > boom > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > sntp > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > cryptiles > boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
warning eslint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
yarn install v1.13.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 52.70s.

创建项目 myAPP 成功!
请进入项目目录 myAPP 开始工作吧!😝
HarrydeMacBook:Desktop harry$ cd myAPP/
HarrydeMacBook:myAPP harry$ npm run dev:rn

> myAPP@1.0.0 dev:rn /Users/harry/Desktop/myAPP
> npm run build:rn -- --watch


> myAPP@1.0.0 build:rn /Users/harry/Desktop/myAPP
> taro build --type rn "--watch"

👽 Taro v1.2.12

开始编译项目 myAPP
module.js:550
    throw err;
    ^

Error: Cannot find module 'fbjs/lib/keyMirror'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/harry/.config/yarn/global/node_modules/@tarojs/cli/src/rn/StyleSheet/ImageResizeMode.js:15:19)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myAPP@1.0.0 build:rn: `taro build --type rn "--watch"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myAPP@1.0.0 build:rn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harry/.npm/_logs/2019-02-09T19_24_19_696Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myAPP@1.0.0 dev:rn: `npm run build:rn -- --watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myAPP@1.0.0 dev:rn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harry/.npm/_logs/2019-02-09T19_24_19_708Z-debug.log
HarrydeMacBook:myAPP harry$ 

期望行为
编译成功

报错信息

开始编译项目 myAPP
module.js:550
    throw err;
    ^

Error: Cannot find module 'fbjs/lib/keyMirror'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/harry/.config/yarn/global/node_modules/@tarojs/cli/src/rn/StyleSheet/ImageResizeMode.js:15:19)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myAPP@1.0.0 build:rn: `taro build --type rn "--watch"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myAPP@1.0.0 build:rn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harry/.npm/_logs/2019-02-09T19_24_19_696Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myAPP@1.0.0 dev:rn: `npm run build:rn -- --watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myAPP@1.0.0 dev:rn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harry/.npm/_logs/2019-02-09T19_24_19_708Z-debug.log
HarrydeMacBook:myAPP harry$ 

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。
Taro v1.2.12

Taro CLI 1.2.12 environment info:
System:
OS: macOS 10.14.2
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.15.0 - ~/.nvm/versions/node/v8.15.0/bin/node
Yarn: 1.13.0 - ~/.yarn/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.15.0/bin/npm
npmPackages:
@tarojs/components: 1.2.12 => 1.2.12
@tarojs/plugin-babel: 1.2.12 => 1.2.12
@tarojs/plugin-csso: 1.2.12 => 1.2.12
@tarojs/plugin-less: 1.2.12 => 1.2.12
@tarojs/plugin-uglifyjs: 1.2.12 => 1.2.12
@tarojs/router: 1.2.12 => 1.2.12
@tarojs/taro: 1.2.12 => 1.2.12
@tarojs/taro-alipay: 1.2.12 => 1.2.12
@tarojs/taro-h5: 1.2.12 => 1.2.12
@tarojs/taro-swan: 1.2.12 => 1.2.12
@tarojs/taro-tt: 1.2.12 => 1.2.12
@tarojs/taro-weapp: 1.2.12 => 1.2.12
@tarojs/webpack-runner: 1.2.12 => 1.2.12
eslint-config-taro: 1.2.12 => 1.2.12
eslint-plugin-taro: 1.2.12 => 1.2.12
nervjs: ^1.3.9 => 1.3.12

补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

@taro-bot
Copy link

taro-bot bot commented Feb 9, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@js-newbee
Copy link
Contributor

js-newbee commented Feb 11, 2019

我这边也是,昨晚 re-install 之后也报这个错了,某个库版本更新了导致?
临时解决方法:进入 taro/cli 安装目录手动添加 fbjs:
cd /usr/local/lib/node_modules/@tarojs/cli && npm install fbjs

上述是 npm 的安装路径,yarn 或者更一般的情况,可以用 which、ls 查找安装路径,如:
which taro
ls -l /usr/local/bin/taro

1550630728417

@taro-bot
Copy link

taro-bot bot commented Feb 12, 2019

CC @Pines-Cheng

@BigBaBei
Copy link

我这边也是,昨晚 re-install 之后也报这个错了,某个库版本更新了导致?
临时解决方法:到 taro/cli 目录下手动添加 fbjs:
cd /usr/local/lib/node_modules/@tarojs/cli && yarn add fbjs

刚学,启动也是报错,这个可用,感谢

@qq471754603
Copy link

我也是这个问题

@ShaoGongBra
Copy link
Contributor

windows在如下目录,仅在win10测试
C:\Users\用户名\AppData\Roaming\npm\node_modules@tarojs\cli>

@eyelly-wu
Copy link
Contributor

问题描述
第一次npm run dev:rn 编译时:Cannot find module 'fbjs/lib/keyMirror'

复现步骤
[复现问题的步骤]

  1. npm install -g @tarojs/cli
  2. taro init myApp
  3. npm run dev:rn
HarrydeMacBook:~ harry$ npm install -g @tarojs/cli
npm WARN deprecated babel-plugin-remove-dead-code@1.3.2: use babel-plugin-minify-dead-code-elimination and babel-plugin-minify-guarded-expressions
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
/Users/harry/.nvm/versions/node/v8.15.0/bin/taro -> /Users/harry/.nvm/versions/node/v8.15.0/lib/node_modules/@tarojs/cli/bin/taro

> fsevents@1.2.7 install /Users/harry/.nvm/versions/node/v8.15.0/lib/node_modules/@tarojs/cli/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download 
[fsevents] Success: "/Users/harry/.nvm/versions/node/v8.15.0/lib/node_modules/@tarojs/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" is installed via remote
npm WARN eslint-plugin-taro@1.2.12 requires a peer of babel-eslint@^8.2.3 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-taro@1.2.12 requires a peer of eslint@^4.15.0 but none is installed. You must install peer dependencies yourself.

+ @tarojs/cli@1.2.12
added 607 packages from 458 contributors in 6.482s

HarrydeMacBook:~ harry$ cd Desktop/
HarrydeMacBook:Desktop harry$ taro init myAPP
👽 Taro v1.2.12

Taro即将创建一个新项目!
Need help? Go and open issue: https://github.com/NervJS/taro/issues/new

? 请输入项目介绍! myAPP
? 是否需要使用 TypeScript ? No
? 请选择 CSS 预处理器(Sass/Less/Stylus) Less
? 请选择模板 默认模板

✔ 创建项目: myAPP
✔ 创建配置目录: myAPP/config
✔ 创建源码目录: myAPP/src
✔ 创建页面目录: myAPP/src/pages
✔ 创建页面 JS 文件: myAPP/src/pages/index/index.js
✔ 创建页面 LESS 文件: myAPP/src/pages/index/index.less
✔ 创建文件: myAPP/src/app.js
✔ 创建文件: myAPP/src/app.less
✔ 创建文件: myAPP/src/index.html
✔ 创建文件: myAPP/config/index.js
✔ 创建文件: myAPP/config/dev.js
✔ 创建文件: myAPP/config/prod.js
✔ 创建文件: myAPP/.editorconfig
✔ 创建文件: myAPP/.gitignore
✔ 创建文件: myAPP/package.json
✔ 创建文件: myAPP/.eslintrc
✔ 创建文件: myAPP/project.config.json

✔ Initialized empty Git repository in /Users/harry/Desktop/myAPP/.git/

✔ 安装成功
warning @tarojs/webpack-runner > webpack-format-messages > kleur@2.0.2: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
warning @tarojs/webpack-runner > node-sass > request > hawk > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > boom > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > sntp > hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
warning @tarojs/webpack-runner > node-sass > request > hawk > cryptiles > boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
warning eslint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
yarn install v1.13.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 52.70s.

创建项目 myAPP 成功!
请进入项目目录 myAPP 开始工作吧!😝
HarrydeMacBook:Desktop harry$ cd myAPP/
HarrydeMacBook:myAPP harry$ npm run dev:rn

> myAPP@1.0.0 dev:rn /Users/harry/Desktop/myAPP
> npm run build:rn -- --watch


> myAPP@1.0.0 build:rn /Users/harry/Desktop/myAPP
> taro build --type rn "--watch"

👽 Taro v1.2.12

开始编译项目 myAPP
module.js:550
    throw err;
    ^

Error: Cannot find module 'fbjs/lib/keyMirror'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/harry/.config/yarn/global/node_modules/@tarojs/cli/src/rn/StyleSheet/ImageResizeMode.js:15:19)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myAPP@1.0.0 build:rn: `taro build --type rn "--watch"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myAPP@1.0.0 build:rn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harry/.npm/_logs/2019-02-09T19_24_19_696Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myAPP@1.0.0 dev:rn: `npm run build:rn -- --watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myAPP@1.0.0 dev:rn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harry/.npm/_logs/2019-02-09T19_24_19_708Z-debug.log
HarrydeMacBook:myAPP harry$ 

期望行为
编译成功

报错信息

开始编译项目 myAPP
module.js:550
    throw err;
    ^

Error: Cannot find module 'fbjs/lib/keyMirror'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/harry/.config/yarn/global/node_modules/@tarojs/cli/src/rn/StyleSheet/ImageResizeMode.js:15:19)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myAPP@1.0.0 build:rn: `taro build --type rn "--watch"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myAPP@1.0.0 build:rn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harry/.npm/_logs/2019-02-09T19_24_19_696Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myAPP@1.0.0 dev:rn: `npm run build:rn -- --watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the myAPP@1.0.0 dev:rn script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/harry/.npm/_logs/2019-02-09T19_24_19_708Z-debug.log
HarrydeMacBook:myAPP harry$ 

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。
Taro v1.2.12

Taro CLI 1.2.12 environment info:
System:
OS: macOS 10.14.2
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.15.0 - ~/.nvm/versions/node/v8.15.0/bin/node
Yarn: 1.13.0 - ~/.yarn/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.15.0/bin/npm
npmPackages:
@tarojs/components: 1.2.12 => 1.2.12
@tarojs/plugin-babel: 1.2.12 => 1.2.12
@tarojs/plugin-csso: 1.2.12 => 1.2.12
@tarojs/plugin-less: 1.2.12 => 1.2.12
@tarojs/plugin-uglifyjs: 1.2.12 => 1.2.12
@tarojs/router: 1.2.12 => 1.2.12
@tarojs/taro: 1.2.12 => 1.2.12
@tarojs/taro-alipay: 1.2.12 => 1.2.12
@tarojs/taro-h5: 1.2.12 => 1.2.12
@tarojs/taro-swan: 1.2.12 => 1.2.12
@tarojs/taro-tt: 1.2.12 => 1.2.12
@tarojs/taro-weapp: 1.2.12 => 1.2.12
@tarojs/webpack-runner: 1.2.12 => 1.2.12
eslint-config-taro: 1.2.12 => 1.2.12
eslint-plugin-taro: 1.2.12 => 1.2.12
nervjs: ^1.3.9 => 1.3.12

补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

我在taro版本1.213和1.2.14都遇到了这个问题,我的解决方案是(/Users/harry/.config/yarn/global/node_modules/@tarojs/cli/src/rn/StyleSheet/ImageResizeMode.js:15:19)根据这个文件定位到@tarojs/cli的下载目录(你的路径可能是/Users/harry/.config/yarn/global/node_modules/@tarojs/cli),通过查看package.json,依赖中是没有fbjs的,在他的目录下通过命令npm i -S fbjs将fbjs依赖加进去,然后在执行npm run dev:rn就可以启动了

@Ghost2016
Copy link

@eyelly-wu 的方法可以解决,原因会不会是这个:facebook/prop-types#194

@eyelly-wu
Copy link
Contributor

@eyelly-wu 的方法可以解决,原因会不会是这个:facebook/prop-types#194

哈哈,是这个原因呢,在@tarojs/cli的package.json中将fbjs依赖(如果我们自己加了的话)移除,将prop-types的版本改成15.6.1或更老(15.6.2就移除fbjs了),npm urn dev:rn可以正常执行,厉害了

@tonylua
Copy link

tonylua commented Mar 5, 2019

@eyelly-wu 的方法可以解决,原因会不会是这个:facebook/prop-types#194

哈哈,是这个原因呢,在@tarojs/cli的package.json中将fbjs依赖(如果我们自己加了的话)移除,将prop-types的版本改成15.6.1或更老(15.6.2就移除fbjs了),npm urn dev:rn可以正常执行,厉害了

全局安装的@tarojs/cli还得找到目录去改一下?

@soymikey
Copy link

如果进去了@taro/cli , npm install fbjs安装如果一直失败, 那就删除@taro 重新安装下npm install -g @tarojs/cli(会安装最新的版本) 然后确定是用管理员打开命令窗口(非管理员模式下不让全局写入),然后执行 npm install fbjs 就可以了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants