【发布时间】:2022-01-25 15:28:05
【问题描述】:
好的,这就是我在 cli 上得到的 任何人如何解决这个问题 我努力了 npm cache clean 但它不工作
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'express'
Require stack:
- C:\Users\iftkh\Backend\index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\iftkh\Backend\index.js:1:17)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\iftkh\\Backend\\index.js' ]
【问题讨论】:
-
确保您在正确的目录中并且您已正确安装 express。
-
hasibur 我放在与我的反应文件相同的目录中
-
我什至清除了所有已安装的 npm,但它仍然没有工作
-
你不能直接在你的 react 应用中使用 express,除非你配置 webpack 来加载 commonJS。
-
将你的 react 和 node js 应用程序分开在不同的目录中。我希望错误会消失