oceanbase/oceanbase-design

[Bug]: <script> `pnpm run dev` is not working in winodws

Closed this issue · 5 comments

"dev": "npx babel --presets @babel/preset-env packages/design/src/theme/index.ts --out-file ./.dumi/tmp/plugin-theme-less/theme.js && UMI_ENV=theme dumi dev",

image

  • should use cross-env when set env variables.
  • Install by pnpm:
pnpm install cross-env --save-dev -w
  • Usage:
cross-env UMI_ENV=theme dumi dev

yes, we should use cross-env to set arg on terminal. But I have a new problem in windows:

  1. install cross-env
  2. update dev script by cross-env UMI_ENV=theme dumi dev
  3. pnpm install
  4. pnpm run start

error:

Unhandled Rejection (Error): Module build failed (from ./node_modules/.pnpm/registry.npmmirror.com+@umijs+bundler-webpack@4.0.72_typescript@5.1.6/node_modules/@umijs/bundler-webpack/compiled/babel-loader/index.js):
SyntaxError: D:\Code\github-work\oceanbase-design\.dumi\pages\index\components\BannerRecommends.tsx?type=meta: Unexpected token, expected "from" (4:12)

�[0m �[90m 2 |�[39m �[36mimport�[39m { �[33mTypography�[39m�[33m,�[39m �[33mCarousel�[39m } �[36mfrom�[39m �[32m'@oceanbase/design'�[39m�[33m;�[39m�[0m
�[0m �[90m 3 |�[39m �[36mimport�[39m { �[33mArrowRightOutlined�[39m } �[36mfrom�[39m �[32m'@oceanbase/icons'�[39m�[33m;�[39m�[0m
�[0m�[31m�[1m>�[22m�[39m�[90m 4 |�[39m �[36mimport�[39m type { �[33mSerializedStyles�[39m } �[36mfrom�[39m �[32m'@emotion/react'�[39m�[33m;�[39m�[0m
�[0m �[90m   |�[39m             �[31m�[1m^�[22m�[39m�[0m
�[0m �[90m 5 |�[39m �[36mimport�[39m { css } �[36mfrom�[39m �[32m'@emotion/react'�[39m�[33m;�[39m�[0m
�[0m �[90m 6 |�[39m �[36mimport�[39m { �[33mLink�[39m } �[36mfrom�[39m �[32m'dumi'�[39m�[33m;�[39m�[0m
�[0m �[90m 7 |�[39m �[36mimport�[39m type { �[33mExtra�[39m�[33m,�[39m �[33mIcon�[39m } �[36mfrom�[39m �[32m'./util'�[39m�[33m;�[39m�[0m
    at instantiate (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:84800:32)
    at constructor (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:85095:12)
    at JSXParserMixin.raise (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:87992:19)
    at JSXParserMixin.unexpected (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:88022:16)
    at JSXParserMixin.expectContextual (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:88341:12)
    at JSXParserMixin.parseImportSpecifiersAndAfter (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:98861:10)
    at JSXParserMixin.parseImport (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:98853:17)
    at JSXParserMixin.parseStatementContent (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:97443:27)
    at JSXParserMixin.parseStatementLike (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:97321:17)
    at JSXParserMixin.parseModuleItem (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:97298:17)
    at JSXParserMixin.parseBlockOrModuleBlockBody (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:97922:36)
    at JSXParserMixin.parseBlockBody (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:97915:10)
    at JSXParserMixin.parseProgram (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:97197:10)
    at JSXParserMixin.parseTopLevel (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:97187:25)
    at JSXParserMixin.parse (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:99084:10)
    at parse (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:99104:26)
    at parser (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:43749:34)
    at parser.next (<anonymous>)
    at normalizeFile (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:45060:38)
    at normalizeFile.next (<anonymous>)
    at run (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:44910:50)
    at run.next (<anonymous>)
    at transform (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:44412:41)
    at transform.next (<anonymous>)
    at step (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:10186:32)
    at D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:10198:13
    at async.call.result.err.err (D:\Code\github-work\oceanbase-design\node_modules\.pnpm\registry.npmmirror.com+@umijs+bundler-utils@4.0.72\node_modules\@umijs\bundler-utils\compiled\babel\index.js:10148:11)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

and more:

__webpack_require__
.root/webpack/bootstrap:24
  21 | 	var execOptions = { id: moduleId, module: module, factory: __webpack_modules__[moduleId], require: __webpack_require__ };
  22 | 	__webpack_require__.i.forEach(function(handler) { handler(execOptions); });
  23 | 	module = execOptions.module;
> 24 | 	execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
     | ^  25 | } catch(e) {
  26 | 	module.error = e;
  27 | 	throw e;

@wzc520pyfm Adding cross-env works for me in MacOS. So It seems unrelated to cross-env. Could removing cross-env fix this error?

image

The pnpm dev won't run on my windows without using cross-env. After using cross-env, the pnpm dev worked fine, but it failed to load after I opened localhost.

The pnpm dev won't run on my windows without using cross-env. After using cross-env, the pnpm dev worked fine, but it failed to load after I opened localhost.

  • Try to update deps by using pnpm update. Welcome to PR with cross-env first.