vue项目引入 element-ui框架

 

vue项目要用到 element-ui ,需要进行安装和引入

官方推荐使用 npm 的方式安装,它能更好地和 webpack 打包工具配合使用。

  • npm i element-ui -S

还需要引入 Element 才能使用。

你可以引入整个 Element,或是根据需要仅引入部分组件。

详情查看官方教程:https://element.eleme.cn/#/zh-CN/component/installation

element-UI 安装报错 ,是缓存问题,参考 这个链接

npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning ERR_STREAM_DESTROYED: Cannot call
 write after a stream was destroyed
npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Program Files\nodejs\node_cache\_cacache\tmp\3ea1b65b
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_cacache\tmp\3ea1b65b'
npm ERR!  [OperationalError: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_cacache\tmp\3ea1b65b']
 {
npm ERR!   cause: [Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_cacache\tmp\3ea1b65b'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'open',
npm ERR!     path: 'C:\\Program Files\\nodejs\\node_cache\\_cacache\\tmp\\3ea1b65b'
npm ERR!   },
npm WARN locking Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_locks\staging-33f9775b7cd6ba50.lock'
npm WARN locking  C:\Program Files\nodejs\node_cache\_locks\staging-33f9775b7cd6ba50.lock failed [Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_locks\staging-33f9775b7cd6ba50
.lock'] {
npm WARN locking   stack: "Error: EPERM: operation not permitted, open 'C:\\Program Files\\nodejs\\node_cache\\_locks\\staging-33f9775b7cd6ba50.lock'",
npm WARN locking   errno: -4048,
npm WARN locking   code: 'EPERM',
npm WARN locking   syscall: 'open',
npm WARN locking   path: 'C:\\Program Files\\nodejs\\node_cache\\_locks\\staging-33f9775b7cd6ba50.lock'
npm WARN locking }
npm WARN [email protected] requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.

npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Program Files\nodejs\node_cache\_locks\staging-33f9775b7cd6ba50.lock
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_locks\staging-33f9775b7cd6ba50.lock'
npm ERR!  [Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\node_cache\_locks\staging-33f9775b7cd6ba50.lock'] {
    

则到 C:\Users\{账户}\ 下 删除  . npmrc 文件。或控制台输入命令 npm cache clean --force 清理缓存。

 

引入element-ui 时报错 :Module build failed: Error: Couldn't find preset "es2015" relative to directory "D:\\code

则 在控制台运行:npm install --save-dev babel-preset-es2015

 

 

你可能感兴趣的:(vue项目引入 element-ui框架)