收藏
回答

如何解决构建NPM提示不允许require变量?

使用js模板开发的微信小程序,但是在构建npm后会弹出1. C:\Users\Mica_Forever\WeChatProjects\miniprogram-1/node_modules/express/lib/view.js:81-81: 不允许require变量的问题,我该如何解决?

//project.config.json
{
  "description""项目配置文件",
  "packOptions": {
    "ignore": [],
    "include": []
  },
  "setting": {
    "bundle"false,
    "userConfirmedBundleSwitch"false,
    "urlCheck"true,
    "scopeDataCheck"false,
    "coverView"true,
    "es6"true,
    "postcss"true,
    "compileHotReLoad"false,
    "lazyloadPlaceholderEnable"false,
    "preloadBackgroundData"false,
    "minified"true,
    "autoAudits"false,
    "newFeature"false,
    "uglifyFileName"false,
    "uploadWithSourceMap"true,
    "useIsolateContext"true,
    "nodeModules"false,
    "enhance"true,
    "useMultiFrameRuntime"true,
    "useApiHook"true,
    "useApiHostProcess"true,
    "showShadowRootInWxmlPanel"true,
    "packNpmManually"false,
    "enableEngineNative"false,
    "packNpmRelationList": [],
    "minifyWXSS"true,
    "showES6CompileOption"false,
    "minifyWXML"true,
    "babelSetting": {
      "ignore": [],
      "disablePlugins": [],
      "outputPath"""
    },
    "condition"false
  },
  "compileType""miniprogram",
  "libVersion""2.19.4",
  "appid""wx4ba2e253c89c03c4",
  "projectname""miniprogram-92",
  "condition": {},
  "editorSetting": {
    "tabIndent""insertSpaces",
    "tabSize"2
  },
  "packNpmManually"true,
    "packNpmRelationList": [
      {
        "packageJsonPath""./package.json",
        "miniprogramNpmDistDir""./miniprogram/"
      }
    ]
  
}

//app.json
{
  "pages":[
    "pages/index/index",
    "pages/logs/logs"
  ],
  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor""#fff",
    "navigationBarTitleText""Weixin",
    "navigationBarTextStyle":"black"
  },
  "sitemapLocation""sitemap.json"
}


回答关注问题邀请回答
收藏

2 个回答

  • 微盟
    微盟
    2023-04-03

    不能用commonjs模块系统。用esmodule。

    2023-04-03
    有用
    回复
  • 赵阳cx330
    赵阳cx330
    2023-04-03

    1.敏感用词,全局搜一下

    2.详情-js编译成es5

    2023-04-03
    有用
    回复
登录 后发表内容