I'm trying to set up an environment for a nuxt.js app. but I'm getting this error every time.
'NUXT_ENV_STAGE' is not recognized as an internal or external command, operable program or batch file.
What does this mean and how can I solve this problem?
package.json
{
"name": "4u2-frontend-business",
"version": "1.0.0",
"description": "4u2 for business",
"author": "fjzy-web",
"private": true,
"workspaces": [
"4u2-common"
],
"scripts": {
"dev": "NUXT_ENV_STAGE=dev PORT=3100 NODE_ENV=development nodemon server/index.js --watch server",
"build": "NUXT_ENV_STAGE=production NODE_ENV=production nuxt build",
"start": "NUXT_ENV_STAGE=production NODE_ENV=production node server/index.js",
"prettier": "prettier --write \"**/*.{vue,js,jsx,json,css}\" --ignore-path .prettierignore && npm run lint",
"generate": "NUXT_ENV_STAGE=production NODE_ENV=production nuxt generate",
"lint": "eslint --fix --ignore-path .gitignore ./src/**/*.{vue,js}",
"et": "node_modules/.bin/et -w -c src/assets/element-variables.scss -o ./assets/theme",
"styleguide": "vue-styleguidist server --config styleguide.config.js",
"styleguide:build": "vue-styleguidist build --config styleguide.config.js",
"test:unit": "jest -c ./jest/jest.config.unit.js --watch",
"test:e2e": "JEST_PUPPETEER_CONFIG=./jest/jest-puppeteer.config.js jest -c ./jest/jest.config.e2e.js --watch"
},
"dependencies": {
"@sentry/integrations": "5.10.2",
"@shopify/app-bridge": "^1.28.0",
"core-js": "3",
"vue-codemirror-lite": "1.0.4"
},
"devDependencies": {
"@vue/test-utils": "1.0.0-beta.31",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "25.1.0",
"jest": "25.1.0",
"jest-puppeteer": "4.4.0",
"puppeteer": "2.1.1",
"sass-loader": "7.3.1",
"vue-jest": "3.0.5",
"vue-styleguidist": "3.22.3"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.js": [
"eslint --fix --cache --ignore-path .gitignore --ext .js",
"git add"
],
"src/**/*.vue": [
"eslint --fix --cache --ignore-path .gitignore --ext .vue",
"git add"
]
}
}
And my nuxt.config.js
file
// my nuxt.config.js file
/* eslint-disable global-require */
const path = require('path')
const webpack = require('webpack')
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin')
const i18n = require('./4u2-common/config/i18n')
require('dotenv').config({ path: `.env.${process.env.NUXT_ENV_STAGE}` })
const isProduction = process.env.NODE_ENV === 'production'
const resolve = (dir) => path.join(__dirname, dir)
module.exports = {
telemetry: false,
srcDir: 'src/',
styleResources: {
scss: '~/assets/css/variables.scss',
},
mode: 'spa',
dir: {
middleware: 'middleware',
},
head: {
title: 'Distribute & Dropshipping Online Customization Products',
meta: [{ charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }],
},
modules: [
'@nuxtjs/axios',
'@nuxtjs/style-resources',
['nuxt-i18n', i18n],
['@nuxtjs/dotenv', { filename: `../.env.${process.env.NUXT_ENV_STAGE}` }],
'@nuxtjs/gtm',
],
gtm: {
id: process.env.GOOGLE_TAG_MANAGER_ID ? process.env.GOOGLE_TAG_MANAGER_ID : '',
enabled: !!process.env.GOOGLE_TAG_MANAGER_ID,
},
env: {
stage: 'dev',
},
plugins: [
'~~/4u2-common/plugins/consoledev.js',
'~~/4u2-common/plugins/lodash.js',
'~/plugins/sentry.js',
'~~/4u2-common/plugins/array-extends.js',
'~~/4u2-common/plugins/i18n-patch.js',
'~~/4u2-common/plugins/price-converter.js',
'~~/4u2-common/plugins/axios/index.js',
'~~/4u2-common/plugins/error-handler.js',
'~~/4u2-common/plugins/dispatch.js',
'~/plugins/init.js',
'~~/4u2-common/plugins/route.js',
'~~/4u2-common/plugins/foru-components.js',
'~~/4u2-common/plugins/swiper.js',
'~~/4u2-common/plugins/vee-validate.js',
'~~/4u2-common/plugins/mixin-methods.js',
'~~/4u2-common/plugins/mixin-filters.js',
'~/plugins/auth',
'~~/4u2-common/plugins/element-ui',
'~/plugins/init-echarts',
'~~/4u2-common/plugins/process',
'~~/4u2-common/plugins/vue-waterfall',
'~~/4u2-common/plugins/directives/directives',
'~~/4u2-common/plugins/forudesigner.js',
],
axios: {
baseURL: process.env.API_BASE_URL + process.env.API_VERSION,
},
render: {
resourceHints: false,
},
// 使vue-router query支持对象
router: {
// https://zh.nuxtjs.org/docs/2.x/features/nuxt-components/#disable-prefetching-globally
prefetchLinks: false,
parseQuery(q) {
return qs.parse(q)
},
stringifyQuery(q) {
q = require('~~/4u2-common/utils/helpers').clearEmpties(q)
const r = qs.stringify(q, { arrayFormat: 'brackets' })
return r ? '?' + r : ''
},
},
/**
* global css
*/
css: [
'~~/4u2-common/assets/css/foru-icon.css',
'~~/4u2-common/assets/css/base.scss',
'~/assets/css/foru-btn.scss',
'~/assets/css/common.scss',
'swiper/dist/css/swiper.css',
],
/*
** Customize the progress bar color
*/
loading: { color: '#3B8070' },
/*
** Build configuration
*/
build: {
cache: true,
parallel: true,
optimization: {
splitChunks: {
chunks: 'all',
automaticNameDelimiter: '.',
maxAsyncRequests: 7,
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial',
},
elementUI: {
name: 'chunk-elementUI',
priority: 20,
test: /[\\/]node_modules[\\/]_?element-ui(.*)/,
},
standardDesigner: {
name: 'standard-designer',
priority: 20,
test: /[\\/]node_modules[\\/]_?standard-designer(.*)/,
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'),
minChunks: 3,
priority: 5,
reuseExistingChunk: true,
},
},
},
},
friendlyErrors: true,
extractCSS: isProduction,
filenames: {
app: ({ isDev }) => (isDev ? '[name].js' : `${process.env.MARKETPLACE}.[name].[chunkhash].js`),
chunk: ({ isDev }) => (isDev ? '[name].js' : `${process.env.MARKETPLACE}.[id].[chunkhash].js`),
css: ({ isDev }) => (isDev ? '[name].css' : `${process.env.MARKETPLACE}.[name].[contenthash].css`),
img: ({ isDev }) =>
isDev ? '[path][name].[ext]' : `${process.env.MARKETPLACE}.img/[name].[contenthash].[ext]`,
font: ({ isDev }) => (isDev ? '[path][name].[ext]' : `${process.env.MARKETPLACE}.fonts/[name].[ext]`),
video: ({ isDev }) => (isDev ? '[path][name].[ext]' : `${process.env.MARKETPLACE}.videos/[name].[ext]`),
},
loaders: {
imgUrl: {
limit: isProduction ? 0.1 : 1000,
},
vue: {
productionMode: isProduction,
transformAssetUrls: {
video: 'src',
source: 'src',
object: 'src',
embed: 'src',
},
},
},
publicPath: '/assets/',
babel: {
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
browsers: ['> 0.1%, edge >= 14, opera >= 60, safari > 11, chrome >= 74, firefox >= 66'],
},
useBuiltIns: 'usage',
corejs: 3,
},
],
],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
[
'@babel/transform-modules-commonjs',
{
allowTopLevelThis: true,
},
],
[
'component',
{
libraryName: 'element-ui',
styleLibraryName: 'theme-chalk',
},
'element-ui',
],
'@babel/transform-async-to-generator',
'@babel/transform-runtime',
'@babel/syntax-dynamic-import',
],
comments: true,
},
plugins: [
new webpack.ProvidePlugin({
qs: 'qs',
}),
new FilterWarningsPlugin({
exclude: /extract-css-chunks-webpack-plugin[^]*Conflicting order/,
}),
],
/**
* Run ESLint on save
* @param {object} config config
*/
extend(config) {
if (isProduction) {
config.devtool = 'source-map'
}
// use fast-sass-loader instead of sass-loader for now
config.module.rules = config.module.rules.map((rule) => {
// sass-loader is only inside "oneOf" attribute
if (!rule.oneOf) {
return rule
}
const new_rule = rule
new_rule.oneOf.map((r) => {
if (!r.use.some((l) => l.loader === 'sass-loader')) {
return r
}
const new_loaders = r
new_loaders.use = new_loaders.use.reduce((loaderAcc, loader) => {
if (loader.loader !== 'sass-loader') {
return [...loaderAcc, ...[loader]]
}
return [
...loaderAcc,
...[
{
loader: 'fast-sass-loader',
options: {
...loader.options,
includePaths: [path.join(__dirname, '/')],
},
},
],
]
}, [])
return new_loaders
})
return new_rule
})
},
},
}