6

解决 Element UI 自定义主题时 primordials is not defined 的问题

 3 years ago
source link: https://shiau.xyz/093cab019db9/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

解决 Element UI 自定义主题时 primordials is not defined 的问题

2021-04-073 分钟

Element UI可以使用命令行主题工具来自定义主题。

在Node.js 15版本下,该工具无法正常工作,报错ReferenceError: primordials is not defined

image-20210407164016490.png

换个思路,不使用命令行主题工具了。直接git clone官方主题theme-chalk,编辑后执行gulp build编译,依旧报这个错误。

经过一番排查,结论就是gulp的版本太低

下面说一下,如何在直接编辑theme-chalk的情况下,顺利通过gulp编译。

打开package.json,把gulp的版本修改为4.0.2,然后重新npm i,再gulp build。这次有了新的错误:

Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (88)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1
    at module.exports (/Users/user/project/theme-chalk/node_modules/node-sass/lib/binding.js:13:13)
    at Object.<anonymous> (/Users/user/project/theme-chalk/node_modules/node-sass/lib/index.js:14:35)

可以看出来,是node-sass的版本太低了,不支持当前的Node.js版本。那么,安装最新的node-sass即可。

npm i [email protected] -D

安装后再gulp build,继续报错:

Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (88)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1
    at module.exports (/Users/user/project/theme-chalk/node_modules/gulp-sass/node_modules/node-sass/lib/binding.js:13:13)
    at Object.<anonymous> (/Users/user/project/theme-chalk/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:14:35)

这次错误依然是node-sass的版本太低,但这次是gulp-sass自己依赖的node-sass版本太低。所以,进入gulp-sass的目录,安装最新的node-sass。

cd ./node_modules/gulp-sass
npm i [email protected] -D

安装后再gulp build,编译成功。

image-20210407164054487.png
正在检查 Disqus 能否访问...

Powered by  & DisqusJS


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK