NODE_ENV=production is not supported in the .env file. Only NODE_ENV=development is supported to create a development build of your project. If you need to set process.env.NODE_ENV, you can set it in the Vite config instead.怎么报错
时间: 2023-06-27 22:03:38 浏览: 6683
这个错误是由于在你的 .env 文件中设置了 NODE_ENV=production,但是在 Vite 中只支持将 NODE_ENV 设置为 development,不能设置为 production。
要解决这个问题,你可以将 .env 文件中的 NODE_ENV=production 注释掉或者删除,然后在 Vite 配置文件中设置 process.env.NODE_ENV 为 production。在 Vite 配置文件中,你可以使用以下代码来设置 NODE_ENV:
```
import { defineConfig } from 'vite';
export default defineConfig({
// 设置 NODE_ENV 为 production
define: {
'process.env.NODE_ENV': JSON.stringify('production')
}
});
```
这样就可以在生产环境下使用 Vite 了。
相关问题
Traceback (most recent call last): File "F:/.astudyNow/graduate_design/ZZSR2018/test_env/myZZSR.py", line 161, in <module> sr_output = final_test(input_img, model) File "F:/.astudyNow/graduate_design/ZZSR2018/test_env/myZZSR.py", line 142, in final_test tmp_output = model(torch.from_numpy(np.transpose(test_input,(2,0,1))).unsqueeze(0)) ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array with array.copy(). 这个报错是什么意思
这个报错是因为你传入的 numpy 数组有负的步长(stride),而 PyTorch 不支持负步长的张量。步长是指相邻两个元素在内存中的距离,如果步长为负,表示元素的存储顺序与轴的顺序相反。
解决这个问题的方法是将 numpy 数组复制一份,使其步长为正。你可以使用 `array.copy()` 方法来复制数组,例如 `test_input = test_input.copy()`。这样就可以避免负步长的问题了。
Epoch 1/10 2023-07-22 21:56:00.836220: W tensorflow/core/framework/op_kernel.cc:1807] OP_REQUIRES failed at cast_op.cc:121 : UNIMPLEMENTED: Cast string to int64 is not supported Traceback (most recent call last): File "d:\AI\1.py", line 37, in <module> model.fit(images, labels, epochs=10, validation_split=0.2) File "D:\AI\env\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "D:\AI\env\lib\site-packages\tensorflow\python\eager\execute.py", line 52, in quick_execute tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, tensorflow.python.framework.errors_impl.UnimplementedError: Graph execution error: Detected at node 'sparse_categorical_crossentropy/Cast' defined at (most recent call last): File "d:\AI\1.py", line 37, in <module> model.fit(images, labels, epochs=10, validation_split=0.2) File "D:\AI\env\lib\site-packages\keras\utils\traceback_utils.py", line 65, in error_handler return fn(*args, **kwargs) File "D:\AI\env\lib\site-packages\keras\engine\training.py", line 1685, in fit tmp_logs = self.train_function(iterator) File "D:\AI\env\lib\site-packages\keras\engine\training.py", line 1284, in train_function return step_function(self, iterator) File "D:\AI\env\lib\site-packages\keras\engine\training.py", line 1268, in step_function outputs = model.distribute_strategy.run(run_step, args=(data,)) File "D:\AI\env\lib\site-packages\keras\engine\training.py", line 1249, in run_step outputs = model.train_step(data) File "D:\AI\env\lib\site-packages\keras\engine\training.py", line 1051, in train_step loss = self.compute_loss(x, y, y_pred, sample_weight) File "D:\AI\env\lib\site-packages\keras\engine\training.py", line 1109, in compute_loss return self.compiled_loss( File "D:\AI\env\lib\site-packages\keras\engine\compile_utils.py", line 265, in __call__ loss_value = loss_obj(y_t, y_p, sample_weight=sw) File "D:\AI\env\lib\site-packages\keras\losses.py", line 142, in __call__ losses = call_fn(y_true, y_pred) File "D:\AI\env\lib\site-packages\keras\losses.py", line 268, in call return ag_fn(y_true, y_pred, **self._fn_kwargs) File "D:\AI\env\lib\site-packages\keras\losses.py", line 2078, in sparse_categorical_crossentropy return backend.sparse_categorical_crossentropy( File "D:\AI\env\lib\site-packages\keras\backend.py", line 5610, in sparse_categorical_crossentropy target = cast(target, "int64") File "D:\AI\env\lib\site-packages\keras\backend.py", line 2304, in cast return tf.cast(x, dtype) Node: 'sparse_categorical_crossentropy/Cast' Cast string to int64 is not supported [[{{node sparse_categorical_crossentropy/Cast}}]] [Op:__inference_train_function_1010]
这个错误是由于标签 `labels` 中的数据类型不正确导致的。`labels` 中的数据应该是整数类型,但是在您的代码中,它们被解析为字符串类型。为了解决这个问题,您需要将标签转换为整数类型。
请尝试在加载数据集时将标签转换为整数类型。修改以下部分的代码:
```python
for file in os.listdir(image_dir):
img_path = os.path.join(image_dir, file)
img = Image.open(img_path).convert('L') # 转换为灰度图像
img = img.resize((100, 100))
img = np.array(img, dtype=np.float32)
images.append(img)
labels.append(file.split('.')[0])
```
修改为:
```python
for file in os.listdir(image_dir):
img_path = os.path.join(image_dir, file)
img = Image.open(img_path).convert('L') # 转换为灰度图像
img = img.resize((100, 100))
img = np.array(img, dtype=np.float32)
images.append(img)
labels.append(int(file.split('.')[0]))
```
这样修改后,将标签转换为整数类型后,应该能够解决 `Cast string to int64 is not supported` 的问题。
阅读全文