简体   繁体   English

ngx-monaco-editor:无法从 node_modules 找到 loader.js 文件

[英]ngx-monaco-editor : unable to find loader.js file from node_modules

I want to include ngx-monaco-editor in my project to create a calculator-like screen on the front-end which shows the text entered as the user clicks on the corresponding buttons.我想在我的项目中包含 ngx-monaco-editor 以在前端创建一个类似计算器的屏幕,该屏幕显示用户单击相应按钮时输入的文本。

I have installed ngx-monaco-editor (version 6.0.0) for the same.我已经安装了 ngx-monaco-editor(版本 6.0.0)。

The dependencies have been included in app.module.ts and I have added the glub to assets in the angular.json file.依赖项已包含在 app.module.ts 中,我已将 glub 添加到 angular.json 文件中的资产中。

app.component.hlml : app.component.hlml :

<ngx-monaco-editor [options]="editorOptions" [(ngModel)]="code"></ngx-monaco-editor>

app.component.ts : app.component.ts :

editorOptions = {theme: 'vs-dark', language: 'javascript'};
code: string= 'function x() {\nconsole.log("Hello world!");\n}';

The editor is not getting rendered.编辑器没有被渲染。 I'm instead getting an error that my loader.js file is not getting found.相反,我收到一个错误,即找不到我的 loader.js 文件。

http://localhost:4200/assets/monaco/vs/loader.js net::ERR_ABORTED 404 (Not Found) @base-editor.js:65 http://localhost:4200/assets/monaco/vs/loader.js net::ERR_ABORTED 404(未找到)@base-editor.js:65

The loader.js file is located at node_modules/ngx-monaco-editor/assets/monaco/vs/loader.js and I'm able to navigate to it. loader.js 文件位于 node_modules/ngx-monaco-editor/assets/monaco/vs/loader.js ,我可以导航到它。

The error is occuring at base-editor.js, line 65. The location for this file is node_modules/ngx-monaco-editor/base-editor.js错误发生在 base-editor.js,第 65 行。此文件的位置是 node_modules/ngx-monaco-editor/base-editor.js

10.0.0 中没有资产文件夹,但在 9.0.0 版本中有我使用它并且它有效。

ngx-monaco-editor requires monaco-editor ngx-monaco-editor需要monaco-editor

  1. Install monaco-editor: npm install monaco-editor安装 monaco-editor: npm install monaco-editor

  2. Add a entry under projects>architect>options>assets in angular.json:在 angular.json 中的projects>architect>options>assets下添加一个条目:

{ "glob": "**/*", "input": "node_modules/monaco-editor", "output": "assets/monaco-editor" }

Changing the input configuration in angular.json enabled the files to be copied over to the dist folder.更改 angular.json 中的输入配置可以将文件复制到 dist 文件夹。 Changing the output configuration allowed the loader.json file to be found.更改输出配置允许找到 loader.json 文件。

暂无
暂无

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

相关问题 模块构建失败(来自./node_modules/sass-loader/lib/loader.js),复合选择器可能不再扩展 - Module build failed (from ./node_modules/sass-loader/lib/loader.js), Compound selectors may no longer be extended 模块构建失败(来自./node_modules/mini-css-extract-plugin/dist/loader.js):ReferenceError:文档未定义 - Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js): ReferenceError: document is not defined internal/modules/cjs/loader.js:960 错误:找不到模块'C:\Users\Sanjai\AppData\Roaming\npm\node_modules\protractor\bin\protractor' - internal/modules/cjs/loader.js:960 Error: Cannot find module 'C:\Users\Sanjai\AppData\Roaming\npm\node_modules\protractor\bin\protractor' 在 angular 应用程序中使用 ngx-monaco-editor 结果为 404 - using ngx-monaco-editor in angular app results in 404 ngx-monaco-editor 第一次加载需要一段时间 - ngx-monaco-editor taking a while to load the first time 我如何在我的反应构建中为摩纳哥编辑器的 loader.js 及其对本地主机的依赖项提供服务 - How do I serve Monaco editor's loader.js and its dependencies on localhost in my react build 找不到模块:内部/模块/cjs/loader.js:969 - Cannot find module: internal/modules/cjs/loader.js:969 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):错误:找不到模块“./src/data” - Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module './src/data' dotenv throw err internal/modules/cjs/loader.js:800 找不到模块 - dotenv throw err internal/modules/cjs/loader.js:800 cant find modules 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js)Vue Js - Module build failed (from ./node_modules/babel-loader/lib/index.js) Vue Js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM