Umi is not recognized as an internal or external command, operable program or batch file

问题

umi推荐使用yarn安装,安装umi后,使用umi提示不是内部或者外部命令。('umi' is not recognized as an internal or external command,operable program or batch file.)

解决

根源在于yarn的global bin目录不在path环境变量的中,解决办法:

  1. 执行yarn global bin, 得到global bin目录
  2. 把global bin目录添加到环境变量path中
  3. 测试 umi -v

4.0.11 • Public • Published 12 hours ago

  • Readme
  • Explore BETA
  • 1 Dependency
  • 0 Dependents
  • 173 Versions

@umijs/create-umi

See our website umijs for more information.

Keywords

none

Install

npm i create-umi

Repository

Gitgithub.com/umijs/umi

Homepage

github.com/umijs/umi/tree/master/packages/create-umi#readme

DownloadsWeekly Downloads

1,953

Version

4.0.11

License

MIT

Unpacked Size

394 kB

Total Files

67

Last publish

12 hours ago

Collaborators

  • Umi is not recognized as an internal or external command, operable program or batch file

Try on RunKit

Report malware

I want to run a React project in my Windows (as a virtual machine of my Mac).

In a Command Prompt, after running yarn to install dependencies. I did yarn start. And it gave me 'HTTPS' is not recognized as an internal or external command error.

> yarn start yarn run v1.13.0 $ HTTPS=true CERT=cert/localhost.crt KEY=cert/localhost.key umi dev 'HTTPS' is not recognized as an internal or external command, operable program or batch file. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Does anyone know how to fix this?

Edit 1:

I upgraded node to v12.16.1 (yarn to 1.13.0, npm to 6.13.4), and did yarn add https and yarn add https-localhost. However, yarn start still returned 'HTTPS' is not recognized as an internal or external command.

umi dev returned 'umi' is not recognized as an internal or external command, operable program or batch file.:

>umi dev 'umi' is not recognized as an internal or external command, operable program or batch file.

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

Pick a username Email AddressPassword

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

General

Can it be used in a production environment?

Umi is the underlying front-end framework of Ant Financial, which has directly or indirectly served 600+ applications, including java, node, H5 wireless, Hybrid applications, pure front-end assets applications, CMS applications, and more.

How do I view the version numbers such as react, react-dom, and react-router?

How to introduce @babel/polyfill?

Install dependencies first,

Then create a new src/global.js with the following contents:

How to dynamically modify the title?

The title can be dynamically modified via react-helmet.

Note: In a hybrid application, if you use react-helmet in the ios web container, you can try react-document-title.

Reporting Error

Object.values is not a function

E.g.

Umi is not recognized as an internal or external command, operable program or batch file

Upgrade the node version and make sure the version is 8.10 or greater.

exports is not defined

E.g.

Umi is not recognized as an internal or external command, operable program or batch file

Check the babel configuration to remove unnecessary presets and plugins.

Plugin umi-plugin-react:pwa initialize failed

E.g.

Umi is not recognized as an internal or external command, operable program or batch file

Make sure you have package.json and have configured the name attribute.

E.g.

Umi is not recognized as an internal or external command, operable program or batch file

This is a problem with the webpack plugin, which does not affect the normal production of CSS files and can be ignored for now.

umi is not an internal or external command

E.g.

Umi is not recognized as an internal or external command, operable program or batch file

You need to configure the NODE_PATH environment variable. If you use yarn, you can get the bin path by executing yarn global bin.

webpack

How to configure additional loader?

For example, I hope .svg not to produce base64, but to generate svg files, which can be configured like this:

CSS

Why don't my imported CSS files take effect?

umi use css modules by default, please write your css as css modules.

Ref:

  • css-modules/css-modules
  • CSS Modules usage tutorial

How to disable CSS modules?

Modify .umirc.js:

However, it is not recommended to turn off css modules for no particular reason.

How to use sass?

Install additional dependencies first,

Then modify .umirc.js:

Test

How to do breakpoint debugging?

Make sure node version is above 8.10 and then execute:

Then open chrome://inspect/#devices in the browser for inspect and breakpoints.

Deployment

After the build access route is refreshed 404?

Several options are available:

  • Use hashHistory instead of history: 'hash' in.umirc.js`
  • Static, with exportStatic: true in .umirc.js
  • The server configures the route fallback to index.html

After the build, the picture is lost?

It may be that the picture is not correctly quoted. You can refer to the code and import the picture correctly.

Use in css, be careful not to use absolute paths

Note: base64 will be taken when the image size is less than 10 k. That is, it will not be copied to the public folder, but will be stored as a base64 resource.

SSR

document is not defined, navigator is not defined, * is not not defined

Why: umiJS SSR executes code first server-side, then client-side. The document, navigator object is only present client-side. Solution:

  1. you absolutely need to have access to it in some React component, you should put that code in componentDidMount or useEffect. This lifecycle method will only be executed on the client.
  2. add the judgment with something like typeof navigator !== 'undefined' or typeof document !== 'undefined'

UMI UI

Umi version is too low, please upgrade to or above

Umi UI requires or above, and this error will be reported if the version of the local project does not match.

The solution is to upgrade to the latest version.

  • If the umi dependency in package.json is automatically matched to the latest version, such as ^ 2.9 or 2.x, delete the node_modules reload dependency.
  • If the umi dependency in package.json does not match the latest version, such as ~2.8 or 2.8.0-beta.1, then it needs to be changed to ^ 2.9 or other matching to the latest version, then Remove node_modules and reload dependencies

EACCES: permission denied create-umi

Umi UI needs to have permission to create projects.

The solution is to raise the prompted path permissions and give execute permissions.。