material-ui - 材料 Ui 导入给出错误“模块构建失败:错误:ENOENT:没有这样的文件或目录”
问题描述
我正在构建一个 Next JS 应用程序。除非我将material-ui导入项目,否则一切都很顺利。使用material-ui,它反复给出错误:
./node_modules/@emotion/styled/dist/styled.browser.esm.js
Module build failed: Error: ENOENT: no such file or directory, open
'D:\ReactProjects\ace\node_modules\@emotion\styled\dist\styled.browser.esm.js'
我删除了material-ui并设置了样式,重新安装但没有影响。有人知道原因吗?
解决方案
您可以尝试创建一个名为的文件并将styled.browser.esm.js
其粘贴到其中并将其放入D:\ReactProjects\ace\node_modules\@emotion\styled\dist\
;
import '@babel/runtime/helpers/extends';
import 'react';
import '@emotion/is-prop-valid';
import createStyled from '../base/dist/emotion-styled-base.browser.esm.js';
import '@emotion/react';
import '@emotion/utils';
import '@emotion/serialize';
var tags = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', // SVG
'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
var newStyled = createStyled.bind();
tags.forEach(function (tagName) {
// $FlowFixMe: we can ignore this because its exposed type is defined by the CreateStyled type
newStyled[tagName] = newStyled(tagName);
});
export default newStyled;
我知道这很奇怪,但似乎 npm 没有将所有文件都放入文件夹中。我通过从存储库中手动获取文件并将其放入我的文件夹中解决了这样的问题。
推荐阅读
- java - Java 中的 AWS 翻译客户端异常 (AWS Comprehend)
- asp.net-core - kestrel 中带有虚拟目录的 ASPNET Core 3.1 Razor 页面
- android - 通过 PdfRenderer 读取 Assets 文件夹中的 PDF 文件而不创建临时文件
- prestashop-1.6 - 如何在数据库(ps_product)Prestashop 中保存自定义字段?
- wordpress - 设置 Cloudflare 后字体未加载
- python - 如何在 matplotlib 子图中旋转 x 轴标签?
- abap - 使用 CL_HTTP_CLIENT 将 json 字符串作为数据发送到外部 api 时出现无效的请求正文错误
- java - Selenium:如何上传文件,如果文件输入元素在打开文件对话框后随后出现在 DOM 中?
- html - 在 Google Chrome 中按 F12 时,如何以紧凑的形式打印 BeautifulSoup 对象?
- vue.js - 访问 Vue 数据时未定义的属性