我有一个正在使用客户端的create-react-app构建的node / express / react应用程序。每当我运行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软件包),因此我不确定是否甚至相关。
如果还有其他应包括在内,请告诉我。
答案 0 :(得分:2)
请运行此命令以解决该错误。
npm i dotenv-expand
答案 1 :(得分:1)
有很多可能导致此问题的问题,即React,npm,程序包源。可能在终端中运行
npm i --save-dev dotenv-expand / yarn add --save-dev dotenv-expand