What I learnt from JS

Use Npx

如果有些包我们只会使用一次,或者只想尝试以下,不想安装到全局,也不想作为当前项目的依赖,可以使用 npx 的方式来执行。

npx 是 npm 5.2+ 版本之后自带的工具,能够帮助我们更高效的执行 npm 软件仓库里的安装包

Use Same Between File Name And Variable

文件的名称要和它所匹配的变量相同,否则代码会出问题,不会报错,但生成的页面有问题 source https://github.com/tianheg/good/commit/b7a0d1111aba1d32c1dcb94f1a3d9e8b342a1c13

Package.json License Should Be A Valid SPDX License Expression

CC BY-NC-SA 4.0 to CC-BY-NC-SA-4.0

source https://spdx.org/licenses/

String Does Not Match The Pattern Of

String does not match the pattern of “^(?:@[a-z0-9-~][a-z0-9-.~]*/)?[a-z0-9-~][a-z0-9-.~]*$”.

Some rules:

  • The name must be less than or equal to 214 characters. This includes the scope for scoped packages.

  • The names of scoped packages can begin with a dot or an underscore. This is not permitted without a scope.

  • New packages must not have uppercase letters in the name.

  • The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.

Some tips:

  • Don’t use the same name as a core Node module.

  • Don’t put “js” or “node” in the name. It’s assumed that it’s js, since you’re writing a package.json file, and you can specify the engine using the “engines” field. (See below.)

  • The name will probably be passed as an argument to require(), so it should be something short, but also reasonably descriptive.

  • You may want to check the npm registry to see if there’s something by that name already, before you get too attached to it. https://www.npmjs.com/

source https://docs.npmjs.com/cli/v7/configuring-npm/package-json#name

Unmet Peer Dependency

When I install packages, something always shows like these:

warning " > @vue/[email protected]" has unmet peer dependency "[email protected]".
warning " > @vue/[email protected]" has unmet peer dependency "[email protected]^2.x".
warning " > [email protected]" has unmet peer dependency "[email protected]^4.0.0 || ^5.0.0".
warning " > [email protected]" has incorrect peer dependency "[email protected]^5.0.0".
warning "eslint-plugin-vue > [email protected]" has incorrect peer dependency "[email protected]^5.0.0".
warning " > [email protected]" has unmet peer dependency "[email protected]^4.36.0 || ^5.0.0".
warning " > [email protected]" has unmet peer dependency "[email protected]^2.x".
warning " > [email protected]" has unmet peer dependency "[email protected]^2.x".
$ npm ls
[email protected] folder path
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected] deduped
......

What’s the meaning of deduped?