这个问题实际上是直接从我如下的回答对前一个问题.
我添加了一个"homepage"到我的,package.json因为它是我在Github Pages上托管的React应用程序.输出npm run build说/build现在可以部署目录,并假定项目正在托管在/project_name/.
但是在localhost上,项目没有被托管/project_name/,因此请求js和css的路径搞砸了(寻找/project_name/static/...而不是/static/...)并且应用程序被破坏了.
如何在package.json中拥有主页字段,以便它们可以部署到Github Pages(例如),同时仍然使用工作应用程序在本地开发?
我想将我的 jest 配置移出我的 package.json,我正在尝试按照此处的建议使用 --config,但出现错误argv.config.match is not a function
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --config jest.config.js",
"eject": "react-scripts eject",
},
Run Code Online (Sandbox Code Playgroud)
hutber@hutber-mac:/var/www/management/node$ npm test -u
> management-fresh@0.1.0 test /var/www/management/node
> react-scripts test --config jest.config.js
Usage: test.js [--config=<pathToConfigFile>] [TestPathPattern]
argv.config.match is not a function
npm ERR! Test failed. See above for more details.
Run Code Online (Sandbox Code Playgroud) 有没有人成功地做到了这一点?我目前已node-sass安装在我的 CRA 项目中,我正在尝试替换它,dart-sass但遇到了困难,因为 CRA 错误输出告诉我我需要node-sass安装。有什么方法可以让底层 CRA 配置知道使用我安装的dart-sass包而不是node-sass?
我在 vs 代码中使用 create-react-app 和 yarn 2 创建了一个新项目。编辑器在导入每个已安装的库时抛出错误,如下所示:
找不到模块“react”或其相应的类型声明。
项目编译并成功运行,但错误仍然存在。当我将文件的扩展名更改为.js和.jsx 时。ts和.tsx,错误消失。我应该如何解决打字稿文件的这个问题?
typescript reactjs visual-studio-code create-react-app yarnpkg
当我运行以下命令时,我在使用CRA创建新的 React 应用程序时遇到问题npx create-react-app my-app。
npm cache clean --forcenpm -g uninstall create-react-app 我的节点版本是v14.15.3,npm 版本是7.10.0
我得到的错误是:
Need to install the following packages:
create-react-app
Ok to proceed? (y)
Run Code Online (Sandbox Code Playgroud) 我是Material UI和ReactJS的新手.我一直在玩Create-React-App(CRA)和reactstrap.我的问题是,我可以一起使用Material UI和CRA来构建应用程序吗?
我想将我的create-react-app项目部署到 GitHub Pages。但我有一些秘密钥匙。如何在 React 应用程序中管理这些密钥?
我正在尝试通过运行来运行 React 服务器 npm start
当我这样做时,我得到一个丢失的脚本错误:
? npm start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aristophanes\AppData\Roaming\npm-cache\_logs\2019-05-15T11_34_47_404Z-debug.log
Run Code Online (Sandbox Code Playgroud)
完整的错误日志:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@6.4.1
3 info using node@v11.1.0
4 verbose stack Error: missing script: start
4 verbose stack at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:155:19)
4 verbose stack …Run Code Online (Sandbox Code Playgroud) 使用npm开始打开create-react-app 时出现以下错误。我是React的新手,过去几天我在做命令行以创建新应用程序时没有遇到任何问题。
我已尝试npx启动,npm启动并npm重新安装更新版本。
Failed to compile
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
BrowserslistError: Unknown browser query `android all`. Maybe you are using old Browserslist or made typo in query.
at Array.reduce (<anonymous>)
at Array.some (<anonymous>)
at Array.filter (<anonymous>)
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个新的 React 应用程序。我有节点版本 14.15.3 和 npm 版本 6.14
Error: Cannot find module 'caniuse-lite/dist/unpacker/agents'
Run Code Online (Sandbox Code Playgroud)
跑步时 npx create-react-app
create-react-app ×10
reactjs ×9
npm ×4
node.js ×2
github ×1
github-pages ×1
javascript ×1
jestjs ×1
material-ui ×1
node-sass ×1
npm-start ×1
npx ×1
sass ×1
testing ×1
typescript ×1
yarnpkg ×1