构建错误:找不到咖啡标注模块

gmzi语言
gmzi语言 成员文章数 :3

Hi所有,我得到这个构建错误

"./node_modules/vm2/lib/compiler.js

模块找不到 : 无法解析 '/Users/me/my-project/node_moles/vm2/lib'

并准备上传图像 Api路由看起来像:

import { NextRequest, NextResponse } from 'next/server'  import {v2 as cloudinary} from 'cloudinary'  const UPLOAD_IMAGE_URL = process.env.UPLOAD_IMAGE_URL  export async function POST(  req,  res) {      try {          const formData = req.body          //cloudinary upload logic goes here          return NextResponse.json({ message: 'Hello Everyone!' })      } catch (e){          console.log(e)          return NextResponse.json({message: 'failed'})      }  }

答案解析

  • 云状团队
    云状团队 管家云工文章数 :87管理员

    报错似乎与Vm2包中缺失模块“coffee-script”相关几步解决问题

    1. 确定新版节点安装可运行查看当前节点js版本节点-五内端使用过期版本时,考虑升级最新稳定发布

    2. 删除节点模式文件夹重新安装依赖关系可用终端运行下列命令实现 :

      m-rf节点npm安装
    3. 重置依存性后问题持久化,Vm2包有可能有依存冲突Vm2软件包可明文更新到特定版本终端运行

      m安装vm2

      安装最新版本vm2包

    4. 上方步骤解决不了问题, 包包本身可能与vm2有依赖冲突 。可强制使用特殊版本vm2Vm2版本3.7.0

      m安装[email protected]

      并试运行程序并查看错误是否持久

    如果这些步骤都无济于事,请提供使用中具体版本的cloudiary和vm2包,并提供任何附加错误消息或栈迹信息帮助深入调查并帮助你解决问题

  • gmzi语言
    gmzi语言 成员文章数 :3

    感谢响应刚试上方所有步骤, 问题仍然存在, 以下是我运行的具体版本:

    特殊性:+1.37.1

    Vm2:+37.0

    下图13.4.2

    类型标注:5.0.4

    试编译时报错

    ./node_modules/degenerator/node_modules/vm2/lib/compiler.js Module not found: Can't resolve 'coffee-script' in '/Users/me/my-project/node_modules/degenerator/node_modules/vm2/lib'  Import trace for requested module: ./node_modules/degenerator/node_modules/vm2/lib/compiler.js ./node_modules/degenerator/node_modules/vm2/lib/script.js ./node_modules/degenerator/node_modules/vm2/lib/main.js ./node_modules/degenerator/node_modules/vm2/index.js ./node_modules/degenerator/dist/src/index.js ./node_modules/pac-resolver/dist/index.js ./node_modules/pac-proxy-agent/dist/agent.js ./node_modules/pac-proxy-agent/dist/index.js ./node_modules/proxy-agent/index.js ./node_modules/cloudinary/lib/utils/index.js ./node_modules/cloudinary/lib/utils/srcsetUtils.js ./node_modules/cloudinary/lib/cloudinary.js ./node_modules/cloudinary/cloudinary.js ./app/api/image/route.tsx  ./node_modules/degenerator/node_modules/vm2/lib/resolver-compat.js Critical dependency: the request of a dependency is an expression  Import trace for requested module: ./node_modules/degenerator/node_modules/vm2/lib/resolver-compat.js ./node_modules/degenerator/node_modules/vm2/lib/main.js ./node_modules/degenerator/node_modules/vm2/index.js ./node_modules/degenerator/dist/src/index.js ./node_modules/pac-resolver/dist/index.js ./node_modules/pac-proxy-agent/dist/agent.js ./node_modules/pac-proxy-agent/dist/index.js ./node_modules/proxy-agent/index.js ./node_modules/cloudinary/lib/utils/index.js ./node_modules/cloudinary/lib/utils/srcsetUtils.js ./node_modules/cloudinary/lib/cloudinary.js ./node_modules/cloudinary/cloudinary.js ./app/api/image/route.tsx  - info Linting and checking validity of types   - info Collecting page data ..Error: ENOENT: no such file or directory, open '/Users/me/my-project/.next/server/chunks/bridge.js'     at Object.openSync (node:fs:601:3)     at Object.readFileSync (node:fs:469:35)     at 78475 (/Users/me/my-project/.next/server/chunks/473.js:54037:120)     at __webpack_require__ (/Users/me/my-project/.next/server/webpack-runtime.js:25:43)     at 86577 (/Users/me/my-project/.next/server/chunks/473.js:51797:17)     at __webpack_require__ (/Users/me/my-project/.next/server/webpack-runtime.js:25:43)     at 40117 (/Users/me/my-project/.next/server/chunks/473.js:50554:18)     at __webpack_require__ (/Users/me/my-project/.next/server/webpack-runtime.js:25:43)     at 88436 (/Users/me/my-project/.next/server/chunks/473.js:50382:15)     at __webpack_require__ (/Users/me/my-project/.next/server/webpack-runtime.js:25:43) {   errno: -2,   syscall: 'open',   code: 'ENOENT',   path: '/Users/me/my-project/.next/server/chunks/bridge.js' }  > Build error occurred Error: Failed to collect page data for /api/image     at /Users/me/my-project/node_modules/next/dist/build/utils.js:1152:15     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {   type: 'Error' }

    以防有帮助,这里是安装vm2@latest后我得到的编译错误

    ./node_modules/vm2/lib/compiler.js Module not found: Can't resolve 'coffee-script' in '/Users/me/my-project/node_modules/vm2/lib'  Import trace for requested module: ./node_modules/vm2/lib/compiler.js ./node_modules/vm2/lib/script.js ./node_modules/vm2/lib/main.js ./node_modules/vm2/index.js ./node_modules/degenerator/dist/src/index.js ./node_modules/pac-resolver/dist/index.js ./node_modules/pac-proxy-agent/dist/agent.js ./node_modules/pac-proxy-agent/dist/index.js ./node_modules/proxy-agent/index.js ./node_modules/cloudinary/lib/utils/index.js ./node_modules/cloudinary/lib/utils/srcsetUtils.js ./node_modules/cloudinary/lib/cloudinary.js ./node_modules/cloudinary/cloudinary.js ./app/api/image/route.tsx  ./node_modules/vm2/lib/resolver-compat.js Critical dependency: the request of a dependency is an expression  Import trace for requested module: ./node_modules/vm2/lib/resolver-compat.js ./node_modules/vm2/lib/main.js ./node_modules/vm2/index.js ./node_modules/degenerator/dist/src/index.js ./node_modules/pac-resolver/dist/index.js ./node_modules/pac-proxy-agent/dist/agent.js ./node_modules/pac-proxy-agent/dist/index.js ./node_modules/proxy-agent/index.js ./node_modules/cloudinary/lib/utils/index.js ./node_modules/cloudinary/lib/utils/srcsetUtils.js ./node_modules/cloudinary/lib/cloudinary.js ./node_modules/cloudinary/cloudinary.js ./app/api/image/route.tsx  - info Linting and checking validity of types   - info Collecting page data ..Error: ENOENT: no such file or directory, open '/Users/me/my-project/.next/server/chunks/bridge.js'     at Object.openSync (node:fs:601:3)     at Object.readFileSync (node:fs:469:35)     at 90260 (/Users/me/my-project/.next/server/chunks/473.js:85507:120)     at __webpack_require__ (/Users/me/my-project/.next/server/webpack-runtime.js:25:43)     at 63232 (/Users/me/my-project/.next/server/chunks/473.js:83267:17)     at __webpack_require__ (/Users/me/my-project/.next/server/webpack-runtime.js:25:43)     at 34088 (/Users/me/my-project/.next/server/chunks/473.js:82024:18)     at __webpack_require__ (/Users/me/my-project/.next/server/webpack-runtime.js:25:43)     at 88436 (/Users/me/my-project/.next/server/chunks/473.js:50382:15)     at __webpack_require__ (/Users/me/my-project/.next/server/webpack-runtime.js:25:43) {   errno: -2,   syscall: 'open',   code: 'ENOENT',   path: '/Users/me/my-project/.next/server/chunks/bridge.js' }  > Build error occurred Error: Failed to collect page data for /api/image     at /Users/me/my-project/node_modules/next/dist/build/utils.js:1152:15     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {   type: 'Error' }
  • 云状团队
    云状团队 管家云工文章数 :87管理员

    你好

    似乎你编译代码有问题错误消息显示缺失coffee-script模块这可能是因为模块没有安装或没有正确安装可尝试安装模块,运行终端命令如下:

    m安装咖啡条

    无效时,可尝试删除节点文件夹并运行m安装再一次

    希望这有帮助有问题通知我
    视界
    维萨姆

    开发者支持工程师
    云化


    加入云化社区


  • Lalapolaanewb
    Lalapolaanewb 成员文章数 :一号
    编辑2023

    台阶安装后我仍面临同样的问题咖啡条人工操作问题更新

    以下是我当前搭建

    节点:18.16.0

    云度:137.2

    接者:13.4.3

  • 塔马拉
    塔马拉 云化员工成员文章数 :71号

    Hi

    并报告主题线程上的问题https://github.com/cloudinary/cloudinary_npm/issues/600

    谢谢

    塔马拉

  • gmzi语言
    gmzi语言 成员文章数 :3
    编辑2023

    感谢Tamara前往主题线程

  • valentino_guerra
    valentino_guerra 成员文章数 :一号

    使用Next.js我将尝试通过基本HTTP请求实现它而不是SDK至少在问题解决前

Baidu
map