gpt4 book ai didi

node.js - 在 nest.js 代码库上找不到模块 (MODULE_NOT_FOUND)

转载 作者:行者123 更新时间:2023-12-04 02:35:45 34 4
gpt4 key购买 nike

我有一个代码库,它在 Node v10.16.3 上的 Windows 机器上运行良好,但是当我尝试在具有 Node v.12.16.3 的 CentOS Linux 机器上安装相同的代码库时,我收到以下错误。不确定问题可能是什么。

# npm start

> nest start

internal/modules/cjs/loader.js:960
throw err;
^

Error: Cannot find module '@angular-devkit/core'
Require stack:
- /usr/local/lib/node_modules/@nestjs/cli/lib/schematics/schematic.option.js
- /usr/local/lib/node_modules/@nestjs/cli/lib/schematics/index.js
- /usr/local/lib/node_modules/@nestjs/cli/actions/generate.action.js
- /usr/local/lib/node_modules/@nestjs/cli/actions/index.js
- /usr/local/lib/node_modules/@nestjs/cli/commands/command.loader.js
- /usr/local/lib/node_modules/@nestjs/cli/commands/index.js
- /usr/local/lib/node_modules/@nestjs/cli/bin/nest.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous>
(/usr/local/lib/node_modules/@nestjs/cli/lib/schematics/schematic.option.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/@nestjs/cli/lib/schematics/schematic.option.js',
'/usr/local/lib/node_modules/@nestjs/cli/lib/schematics/index.js',
'/usr/local/lib/node_modules/@nestjs/cli/actions/generate.action.js',
'/usr/local/lib/node_modules/@nestjs/cli/actions/index.js',
'/usr/local/lib/node_modules/@nestjs/cli/commands/command.loader.js',
'/usr/local/lib/node_modules/@nestjs/cli/commands/index.js',
'/usr/local/lib/node_modules/@nestjs/cli/bin/nest.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Exit status 1
npm ERR!
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! /root/.npm/_logs/2020-05-22T14_14_24_709Z-debug.log

最佳答案

删除 dist 文件夹并再次运行 yarn start , npm start , yarn start:devnpm run start:dev重建 dist 文件夹。另外yarn prebuildnpm run prebuild使用 rimraf 做同样的事情
当您更改名称和 tsc 时会出现问题。不会在 dist 中更改它并转译 .js文件,所以它找不到模块
我认为据我所知,nestjs 或 tsc 这样做是为了加快转译速度

关于node.js - 在 nest.js 代码库上找不到模块 (MODULE_NOT_FOUND),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61957145/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com