[英]npm run build fails with create-react-app
我有一个node / express / react应用程序,我正在使用create-react-app为客户端构建。 每当我运行npm run build
我都会收到此错误:
> frontend@0.1.0 build /Users/crescentfresh/myApp/client
> react-scripts build
module.js:487
throw err;
^
Error: Cannot find module 'dotenv-expand'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at dotenvFiles.forEach.dotenvFile (/Users/crescentfresh/myApp/client/node_modules/react-scripts/config/env.js:43:5)
at Array.forEach (native)
at Object.<anonymous> (/Users/crescentfresh/myApp/client/node_modules/react-scripts/config/env.js:41:13)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/crescentfresh/.npm/_logs/2018-10-09T23_53_36_314Z-debug.log
这是我的create-react-app目录的package.json:
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"proxy": {
"/api/*": {
"target": "http://localhost:3000"
}
},
"dependencies": {
"@uppy/core": "^0.27.3",
"@uppy/dashboard": "^0.27.5",
"@uppy/react": "^0.27.5",
"@uppy/tus": "^0.27.5",
"apollo-cache-inmemory": "^1.2.5",
"apollo-client": "^2.3.5",
"apollo-link": "^1.2.2",
"apollo-link-error": "^1.1.0",
"apollo-link-http": "^1.5.4",
"apollo-link-state": "^0.4.1",
"axios": "^0.18.0",
"bootstrap": "^4.1.1",
"graphql": "^0.13.2",
"graphql-tag": "^2.9.2",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-apollo": "^2.1.9",
"react-dom": "^16.4.1",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "2.0.3",
"react-spinners": "^0.4.5",
"reactstrap": "^6.2.0",
"recompose": "^0.29.0"
},
"scripts": {
"start": "cross-env PORT=3003 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"cross-env": "^5.2.0"
}
}
这用于构建但最近开始失败。 我尝试删除在失败的构建发生之前添加的软件包,但这没有帮助(uppy和axios软件包)所以我不确定这是否甚至相关。
如果还有其他什么我应该包括请告诉我。
请运行此命令以解决该错误。
npm i dotenv-expand
有很多问题可能导致这个问题,即React,npm,包源。也许在终端运行这个npm i --save-dev dotenv-expand / yarn add --save-dev dotenv-expand
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.