我已经尝试寻找其他问题,但都存在相同的问题,但是当使用.env文件(其中之一具有空字符串作为值)时,显然没有人遇到过vue-cli-3故事书设置的问题
我同时运行TypeError: Cannot read property 'match' of undefined
和npm run storybook:serve
来启动应用程序本身时收到错误npm run serve
。
我试图弄清楚为什么空字符串不只是空字符串而不是未定义。我在console.logs
中做了..\node_modules\dotenv-expand\lib\main.js
,但到目前为止我还没有头绪...
我的.env.development文件包含:
VUE_APP_ENVIDAT_PROXY=
VUE_APP_SOLR_PROXY=
和带有
的.env.production文件VUE_APP_ENVIDAT_PROXY=some/url
VUE_APP_SOLR_PROXY=some/url
vue.config.js只是:
module.exports = {
runtimeCompiler: true,
};
我还尝试初始化dotenv并将其添加到vue.config.js之上。
const dotenv = require('dotenv');
dotenv.config();
process.env.VUE_APP_VERSION = require('./package.json').version;
console.log(`starting ${process.env.VUE_APP_VERSION}`);
没有用,但我仍然收到错误消息:
ERR! TypeError: Cannot read property 'match' of undefined
ERR! at interpolate (D:\EnviDat\Frontend\envidat_frontend\node_modules\dotenv-expand\lib\main.js:8:28)
ERR! at dotenvExpand (D:\EnviDat\Frontend\envidat_frontend\node_modules\dotenv-expand\lib\main.js:52:32)
ERR! at D:\EnviDat\Frontend\envidat_frontend\node_modules\lazy-universal-dotenv\lib\index.cjs.js:36:36
ERR! at Array.forEach (<anonymous>)
ERR! at getEnvironment (D:\EnviDat\Frontend\envidat_frontend\node_modules\lazy-universal-dotenv\lib\index.cjs.js:31:15)
ERR! at loadEnv (D:\EnviDat\Frontend\envidat_frontend\node_modules\@storybook\core\dist\server\config\utils.js:49:47)
ERR! at _default (D:\EnviDat\Frontend\envidat_frontend\node_modules\@storybook\core\dist\server\manager\manager-webpack.config.js:64:26)
ERR! at Object.managerWebpack (D:\EnviDat\Frontend\envidat_frontend\node_modules\@storybook\core\dist\server\manager\manager-preset.js:39:38)
ERR! at accumulationPromise.then.newConfig (D:\EnviDat\Frontend\envidat_frontend\node_modules\@storybook\core\dist\server\presets.js:80:72)
ERR! at <anonymous>
ERR! at process._tickCallback (internal/process/next_tick.js:188:7)
ERR! { TypeError: Cannot read property 'match' of undefined
ERR! at interpolate (D:\EnviDat\Frontend\envidat_frontend\node_modules\dotenv-expand\lib\main.js:8:28)
ERR! at dotenvExpand (D:\EnviDat\Frontend\envidat_frontend\node_modules\dotenv-expand\lib\main.js:52:32)
ERR! at D:\EnviDat\Frontend\envidat_frontend\node_modules\lazy-universal-dotenv\lib\index.cjs.js:36:36
ERR! at Array.forEach (<anonymous>)
ERR! at getEnvironment (D:\EnviDat\Frontend\envidat_frontend\node_modules\lazy-universal-dotenv\lib\index.cjs.js:31:15)
ERR! at loadEnv (D:\EnviDat\Frontend\envidat_frontend\node_modules\@storybook\core\dist\server\config\utils.js:49:47)
ERR! at _default (D:\EnviDat\Frontend\envidat_frontend\node_modules\@storybook\core\dist\server\manager\manager-webpack.config.js:64:26)
ERR! at Object.managerWebpack (D:\EnviDat\Frontend\envidat_frontend\node_modules\@storybook\core\dist\server\manager\manager-preset.js:39:38)
ERR! at accumulationPromise.then.newConfig (D:\EnviDat\Frontend\envidat_frontend\node_modules\@storybook\core\dist\server\presets.js:80:72)
ERR! at <anonymous>
ERR! at process._tickCallback (internal/process/next_tick.js:188:7)
```