简体   繁体   English

什么“模块{路径} \\ src \\ app \\ sales \\ models \\ index.ts没有静态导出”是​​什么意思,我该如何解决?

[英]What does “Module {path}\src\app\sales\models\index.ts has no static exports” mean and how do I fix it?

We've just added webpack 3.0.0 to our angular 2 project. 我们刚刚将webpack 3.0.0添加到了angular 2项目中。 I had it working, got about a 20-25% performance improvement and a 50% (ish) decrease in size. 我有它的工作,性能提高了20-25%,尺寸减少了50%(ish)。 I then rebased this onto the main branch and started to get the error. 然后我将其重新定位到主分支上并开始得到错误。

ERROR in chunk main [initial]
[name].bundle.js
Module \src\app\sales\models\index.ts has no static exports true

What does that error actually mean? 这个错误究竟意味着什么? I haven't been able to find anything useful online. 我在网上找不到任何有用的东西。 Any tips on fixing it? 修理它的任何提示?

The \\src\\app\\sales\\models\\index.ts file hasn't changed since my commit and only contains: 自我提交以来, \\src\\app\\sales\\models\\index.ts文件没有更改,只包含:

export * from './app-state';
export * from './purchase.model';
export * from './base.model';
export * from './view-state.model';
export * from './address';
export * from './core';
export * from './cover';
export * from './disclaimers';
export * from './family';
export * from './premium';
export * from './payments';
export * from './policy';
export * from './tracking.model';

After undoing my initial rebase I rebased the main on branch on top of my work and then found the commit that "broke" webpack (thank goodness for git bisect ) and I'm in the process of slowly walking the changes back in to see if I can keep it working. 解开我最初的底垫后,我重订基期的主要分支对我的工作的顶部,然后发现触犯该“爆发”的WebPack(用于谢天谢地git bisect ),我在慢慢往回走在变化,看看过程我可以继续工作。

Looking at the webpack source the error is being thrown ConcatenatedModule.js in HarmonyImportSpecifierDependencyConcatenatedTemplate 查看webpack源错误正在HarmonyImportSpecifierDependencyConcatenatedTemplate中抛出ConcatenatedModule.js

    if(!Array.isArray(module.providedExports))
        throw new Error(`Module ${module.resource} has no static exports ${module.providedExports}`);

Some poking around has shown that module.providedExports is a boolean with a value of true , hence the error; 一些讨论表明module.providedExports是一个值为true的布尔值,因此错误; however, I've not been able to workout what sets that value. 但是,我无法锻炼那些设定价值的东西。

What does the error mean? 错误是什么意思? Other debugging tips? 其他调试技巧?

I have this problem too. 我也有这个问题。 I don't know why this error is throws but i have fix it in replace '*' by explicit export. 我不知道为什么会抛出这个错误,但是我已经通过显式导出替换'*'来修复它。

for example : 例如 :

before : 之前:

export * from './foo';
export * from './bar';

after : 之后:

export {Foo1, Foo2, /*...*/} from './foo';
export {Bar1, Bar2, /*...*/} from './bar'

如何修复“无法分配给 object 的只读属性“导出”'#<object> ' 将第二个 function 添加到 module.exports 时?<div id="text_translate"><p> 不幸的是,我已经被困了大约 5 天了。 我用谷歌搜索过,没有什么对我有用。 我有一个 utils.js 文件,里面有很多东西可以帮助我。 当我将 function "doesUserContainRoles" 添加到导出时,我的 Chrome 控制台给了我错误:</p><blockquote><p> Uncaught TypeError: Cannot assign to read only property 'exports' of object '#&lt;Object&gt;'</p></blockquote><p> 当我删除 function 时,utils 文件中的所有内容都可以完美运行,根本没有 0 个问题。 只要我添加 function,我就会收到此错误。 我通过以下方式要求 utils 文件:</p><pre class="lang-js prettyprint-override"> const utils = require("../../../utils");</pre><p> 并且没有与此一起使用的import 。 (我知道module.exports和import不能一起工作)</p><p> 我正在使用什么:</p><ul><li><p> Vue.js @vue/cli 4.5.8</p></li><li><p> Node.js v15.2.0</p></li></ul><h3> 文件:</h3><p> utils.js</p><pre class="lang-js prettyprint-override"> const winston = require("winston"); const { datadog } = require("./credentials.js"); const { createLogger, format, transports } = require('winston'); const base_url = "http://localhost:3001/api/v1" // Winston ~ const httpTransportOptions = { host: datadog.logger.host, path: datadog.logger.path, ssl: datadog.logger.ssl }; const customLevels = { levels: { emergency: 0, alert: 1, critical: 2, error: 3, warn: 4, notice: 5, info: 6, debug: 7, success: 8 }, } const logger = createLogger({ level: 'info', levels: customLevels.levels, exitOnError: false, format: format.json(), transports: [ new transports.Http(httpTransportOptions), ], }); const commonMessages = { accessPage: "User Accessed a Page", restrictedPage: "Attempt at accessing restricted page" } function alertGeneral() { alert("Oops. An error has occurred. Please try again later, If this problem continues. please contact Vinniehat;"), } function doesUserContainRoles(userRoles. containsRoles) { return.;userRoles.some(role =&gt; containsRoles,includes(role)), } module,exports = { logger, commonMessages, base_url, alertGeneral, doesUserContainRoles }</pre><p> 这是错误堆栈:</p><pre> Uncaught TypeError: Cannot assign to read only property 'exports' of object '#&lt;Object&gt;' at Module.eval (utils.js?1b23:45) at eval (utils.js:68) at Module../utils.js (app.js:1944) at __webpack_require__ (app.js:854) at fn (app.js:151) at eval (router.js?9883:19) at Module../src/router/router.js (app.js:1812) at __webpack_require__ (app.js:854) at fn (app.js:151) at eval (main.js:34)</pre><p> 我也尝试使用export default 。 这样做时,我的前端工作。 网站加载没有错误。 不过,我的后端使用 Express.js 运行,然后引发错误:</p><pre> Unhandled rejection E:\Development\Websites\iceberg-gaming-website\utils.js:45 export default { ^^^^^^ SyntaxError: Unexpected token 'export' at wrapSafe (node:internal/modules/cjs/loader:1018:16) at Module._compile (node:internal/modules/cjs/loader:1066:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10) at Module.load (node:internal/modules/cjs/loader:967:32) at Function.Module._load (node:internal/modules/cjs/loader:807:14) at Module.require (node:internal/modules/cjs/loader:991:19) at require (node:internal/modules/cjs/helpers:92:18) at Object.&lt;anonymous&gt; (E:\Development\Websites\iceberg-gaming-website\express\modules\user.js:9:15) at Module._compile (node:internal/modules/cjs/loader:1102:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10) at Module.load (node:internal/modules/cjs/loader:967:32) at Function.Module._load (node:internal/modules/cjs/loader:807:14) at Module.require (node:internal/modules/cjs/loader:991:19) at require (node:internal/modules/cjs/helpers:92:18) at E:\Development\Websites\iceberg-gaming-website\express\express.js:27:27 at tryCatcher (E:\Development\Websites\iceberg-gaming-website\node_modules\bluebird\js\release\util.js:16:23)</pre></div></object> - How do I fix 'Cannot assign to read only property 'exports' of object '#<Object>' when adding a 2nd function to module.exports?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否所有 index.ts 导出都加载到模块中 - Does all index.ts exports load into modules 这个错误是什么意思,我该如何解决? - What does this error mean and how do I fix it? Typescript index.ts 激活时出现错误“未找到模块” - ERROR "MODULE NOT FOUND" on Typescript index.ts activation “ var self = module.exports;”是什么意思? - what does “var self = module.exports;” mean? 如何正确导出和导入 cypress 插件 index.ts 的函数? - How to correctly export and import functions for cypress plugin index.ts? 正则表达式:所有以.ts结尾且没有单词index.ts和test.ts的字符串 - Regex: All strings that finishes with .ts and does not have the word index.ts and test.ts 在NodeJS / Express中,“module.exports”和“exports.methods”是什么意思? - What do “module.exports” and “exports.methods” mean in NodeJS / Express? 如何修复“无法分配给 object 的只读属性“导出”'#<object> ' 将第二个 function 添加到 module.exports 时?<div id="text_translate"><p> 不幸的是,我已经被困了大约 5 天了。 我用谷歌搜索过,没有什么对我有用。 我有一个 utils.js 文件,里面有很多东西可以帮助我。 当我将 function "doesUserContainRoles" 添加到导出时,我的 Chrome 控制台给了我错误:</p><blockquote><p> Uncaught TypeError: Cannot assign to read only property 'exports' of object '#&lt;Object&gt;'</p></blockquote><p> 当我删除 function 时,utils 文件中的所有内容都可以完美运行,根本没有 0 个问题。 只要我添加 function,我就会收到此错误。 我通过以下方式要求 utils 文件:</p><pre class="lang-js prettyprint-override"> const utils = require("../../../utils");</pre><p> 并且没有与此一起使用的import 。 (我知道module.exports和import不能一起工作)</p><p> 我正在使用什么:</p><ul><li><p> Vue.js @vue/cli 4.5.8</p></li><li><p> Node.js v15.2.0</p></li></ul><h3> 文件:</h3><p> utils.js</p><pre class="lang-js prettyprint-override"> const winston = require("winston"); const { datadog } = require("./credentials.js"); const { createLogger, format, transports } = require('winston'); const base_url = "http://localhost:3001/api/v1" // Winston ~ const httpTransportOptions = { host: datadog.logger.host, path: datadog.logger.path, ssl: datadog.logger.ssl }; const customLevels = { levels: { emergency: 0, alert: 1, critical: 2, error: 3, warn: 4, notice: 5, info: 6, debug: 7, success: 8 }, } const logger = createLogger({ level: 'info', levels: customLevels.levels, exitOnError: false, format: format.json(), transports: [ new transports.Http(httpTransportOptions), ], }); const commonMessages = { accessPage: "User Accessed a Page", restrictedPage: "Attempt at accessing restricted page" } function alertGeneral() { alert("Oops. An error has occurred. Please try again later, If this problem continues. please contact Vinniehat;"), } function doesUserContainRoles(userRoles. containsRoles) { return.;userRoles.some(role =&gt; containsRoles,includes(role)), } module,exports = { logger, commonMessages, base_url, alertGeneral, doesUserContainRoles }</pre><p> 这是错误堆栈:</p><pre> Uncaught TypeError: Cannot assign to read only property 'exports' of object '#&lt;Object&gt;' at Module.eval (utils.js?1b23:45) at eval (utils.js:68) at Module../utils.js (app.js:1944) at __webpack_require__ (app.js:854) at fn (app.js:151) at eval (router.js?9883:19) at Module../src/router/router.js (app.js:1812) at __webpack_require__ (app.js:854) at fn (app.js:151) at eval (main.js:34)</pre><p> 我也尝试使用export default 。 这样做时,我的前端工作。 网站加载没有错误。 不过,我的后端使用 Express.js 运行,然后引发错误:</p><pre> Unhandled rejection E:\Development\Websites\iceberg-gaming-website\utils.js:45 export default { ^^^^^^ SyntaxError: Unexpected token 'export' at wrapSafe (node:internal/modules/cjs/loader:1018:16) at Module._compile (node:internal/modules/cjs/loader:1066:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10) at Module.load (node:internal/modules/cjs/loader:967:32) at Function.Module._load (node:internal/modules/cjs/loader:807:14) at Module.require (node:internal/modules/cjs/loader:991:19) at require (node:internal/modules/cjs/helpers:92:18) at Object.&lt;anonymous&gt; (E:\Development\Websites\iceberg-gaming-website\express\modules\user.js:9:15) at Module._compile (node:internal/modules/cjs/loader:1102:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10) at Module.load (node:internal/modules/cjs/loader:967:32) at Function.Module._load (node:internal/modules/cjs/loader:807:14) at Module.require (node:internal/modules/cjs/loader:991:19) at require (node:internal/modules/cjs/helpers:92:18) at E:\Development\Websites\iceberg-gaming-website\express\express.js:27:27 at tryCatcher (E:\Development\Websites\iceberg-gaming-website\node_modules\bluebird\js\release\util.js:16:23)</pre></div></object> - How do I fix 'Cannot assign to read only property 'exports' of object '#<Object>' when adding a 2nd function to module.exports? 如何在我的 index.js / discord.js 中传递 module.exports - How do I pass module.exports in my index.js / discord.js 模块导出= mongoose模型在NodeJ中做了什么 - what does module exports = mongoose model do in NodeJs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM