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

茶叶蛋 run dev 路径问题 #2335

Closed
waitingsong opened this issue Apr 7, 2018 · 5 comments
Closed

茶叶蛋 run dev 路径问题 #2335

waitingsong opened this issue Apr 7, 2018 · 5 comments
Assignees

Comments

@waitingsong
Copy link
Contributor

  • Node Version: 8.10.0
  • Egg Version: 2.6.0
  • Plugin Name:
  • Plugin Version:
  • Platform:
  • Mini Showcase Repository:

参照 本文 步骤

$ npx egg-init --type=ts showcase
$ cd showcase && npm i
$ npm run dev

中途出现错误,把 node_modules 改名为 node_modules0 (因为删除目录比较卡所以习惯是改名后重新执行 npm i)。 然后再执行 npm run dev 就报错了

$ npm run dev

> [email protected] dev E:\project\egg\eggjs-examples\framework-ts2\yadan
> egg-bin dev -r egg-ts-helper/register

[egg-ts-helper] E:\project\egg\eggjs-examples\framework-ts2\yadan\typings\app\controller\index.d.ts created
[egg-ts-helper] E:\project\egg\eggjs-examples\framework-ts2\yadan\typings\config\index.d.ts created
[egg-ts-helper] E:\project\egg\eggjs-examples\framework-ts2\yadan\typings\app\service\index.d.ts created
2018-04-07 18:04:17,639 INFO 3972 [master] node version v8.10.0
2018-04-07 18:04:17,654 INFO 3972 [master] egg version 2.6.0
Error: ENOENT: no such file or directory, scandir 'E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules0\babel-plugin-tran                  sform-function-bind'
    at Object.fs.readdirSync (fs.js:904:18)
    at exports.readdir (E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\@mrmlnc\readdir-enhanced\lib\sync\fs.js:18:20                  )
    at Object.safeCall [as safe] (E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\@mrmlnc\readdir-enhanced\lib\call.j                  s:24:8)
    at DirectoryReader.readNextDirectory (E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\@mrmlnc\readdir-enhanced\li                  b\directory-reader.js:78:10)
    at Readable.DirectoryReader.stream._read (E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\@mrmlnc\readdir-enhance                  d\lib\directory-reader.js:57:18)
    at Readable.read (_stream_readable.js:442:10)
    at maybeReadMore_ (_stream_readable.js:536:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    at Function.Module.runMain (module.js:695:11)
internal/child_process.js:392
      throw errnoException(err, 'kill');
      ^

Error: kill ENOSYS
    at _errnoException (util.js:1022:11)
    at ChildProcess.kill (internal/child_process.js:392:13)
    at process.close (E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\egg-ts-helper\src\register.ts:20:10)
    at emitOne (events.js:121:20)
    at process.emit (events.js:211:7)
    at process.emit (E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\source-map-support\source-map-support.js:452:21)
    at process.exit (internal/process.js:157:15)
    at printErrorAndExit (E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\source-map-support\source-map-support.js:43                  6:11)
    at process.emit (E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\source-map-support\source-map-support.js:448:16)
    at process._fatalException (bootstrap_node.js:375:26)
⚠️  Error: E:\project\egg\eggjs-examples\framework-ts2\yadan\node_modules\egg-bin\lib\start-cluster {"typescript":true,"baseDir":"E:\                  \project\\egg\\eggjs-examples\\framework-ts2\\yadan","framework":"E:\\project\\egg\\eggjs-examples\\framework-ts2\\yadan\\node_modul                  es\\egg","workers":1} exit with code 7
⚠️  Command Error, enable `DEBUG=common-bin` for detail

为何会去读取 '...\node_modules0\babel-plugin-tran 这个目录呢

@waitingsong
Copy link
Contributor Author

waitingsong commented Apr 7, 2018

然后执行 npm run clean 继续出错

$ npm run clean

> [email protected] clean E:\project\egg\eggjs-examples\framework-ts2\yadan
> ets clean

module.js:549
    throw err;
    ^

Error: Cannot find module 'E:\project\egg\eggjs-examples\framework-ts2\yadan\bin-clean'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3

...\yadan\bin-clean 这个路径更奇特了

@waitingsong
Copy link
Contributor Author

waitingsong commented Apr 7, 2018

删除 node_modules0 目录后正常。
按理说没有驻留程序,修改了 node_modules 目录重新 npm i 不会有副作用的。我在测试 ng, ionic 以及其他程序时也这么改名干着从来没遇到过类似问题。

@whxaxes whxaxes self-assigned this Apr 8, 2018
@whxaxes
Copy link
Member

whxaxes commented Apr 8, 2018

在我的机子上 run clean 没出现问题,但是 run dev 会抛错,不过错误信息跟你的不一样,ts 会去扫描目录下所有目录,除了 node_modules 目录,但是如果你只是把 node_modules 改成 node_modules0 ,那么 ts 就也会去扫描,怀疑是这一块导致出了什么问题.

@waitingsong
Copy link
Contributor Author

waitingsong commented Apr 8, 2018

我其他项目的 tsconfig.json 里面一般都有个排除条目 'node_modules*' (有个星号结尾) 。应该是这个生效避免了些问题吧

@waitingsong
Copy link
Contributor Author

添加忽略目录后问题解决
PR

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

No branches or pull requests

3 participants