久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Electron 中找不到模塊

Cannot find module in Electron(在 Electron 中找不到模塊)
本文介紹了在 Electron 中找不到模塊的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我目前正在與 Babylon 合作開發 Electron.我找到了 這個 repo,我基本上將它用作我自己項目的樣板.在我嘗試添加 jquery.pep.js 以滿足其他需求之前,一切都運行良好.我一直犯這個錯誤:

I am currently working on Electron with Babylon. I found this repo which I basically used as a boilerplate for my own project. Everything was working well until I tried to add jquery.pep.js for other needs. I keep on having this mistake :

未捕獲的錯誤:找不到模塊jquery.pep.js"

Uncaught Error: Cannot find module 'jquery.pep.js'

我使用npm i -S jquery"和npm i -S jquery.pep.js"安裝了這兩個庫.為了使 jquery 正常工作,我在 index.html 的頭部添加了這個腳本

I installed both libraries with "npm i -S jquery" and "npm i -S jquery.pep.js". In order to make jquery works, I added this script in the head of my index.html

<script> delete window.module; </script>

我的 main.js 頂部的這一行:

and this line in the top of my main.js :

window.$ = window.jQuery = require('jquery');

現在,jquery 工作正常,但由于某些原因,仍然找不到 jquery.pep.js 模塊.我嘗試使用'require'但我有同樣的錯誤

Now, jquery is working fine but for some reasons, jquery.pep.js module still can't be found. I tried to use 'require' but I have the same error

ma??in.js

window.$ = window.jQuery = require('jquery'); 
var pep = require('jquery.pep.js');

項目結構

CSS/
圖片/
js/
-- main.js
節點模塊/
index.html
index.js
包.json
渲染器.js

Project structure

css/
img/
js/
-- main.js
node_modules/
index.html
index.js
package.json
renderer.js

推薦答案

您正在請求某些內容,但節點無法找到它.你可以閱讀這篇關于在 node 中需要模塊,這很簡單地解釋了它.引用:

You are requesting something and node is not able to find it. You can read this dedicated article on requiring modules in node, which explains it quite simply. Quoting:

當我們需要一個find-me"模塊時,沒有指定路徑:

When we require a 'find-me' module, without specifying a path:

require('find-me');

Node 將在所有指定的路徑中查找 find-me.jsmodule.paths — 按順序.

Node will look for find-me.js in all the paths specified by module.paths?—?in order.

$ node
> module.paths
[ '/Users/samer/learn-node/repl/node_modules',
  '/Users/samer/learn-node/node_modules',
  '/Users/samer/node_modules',
  '/Users/node_modules',
  '/node_modules',
  '/Users/samer/.node_modules',
  '/Users/samer/.node_libraries',
  '/usr/local/Cellar/node/7.7.1/lib/node' ]

paths 列表基本上是 node_modules 目錄下的列表從當前目錄到根目錄的每個目錄.它還包括一些不推薦使用的遺留目錄.

The paths list is basically a list of node_modules directories under every directory from the current directory to the root directory. It also includes a few legacy directories whose use is not recommended.

如果 Node 在這些路徑中都找不到 find-me.js,它會拋出一個找不到模塊錯誤."

If Node can’t find find-me.js in any of these paths, it will throw a "cannot find module error."

~/learn-node $ node
> require('find-me')
Error: Cannot find module 'find-me'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at repl:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:23:33)
    at REPLServer.defaultEval (repl.js:336:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.onLine (repl.js:533:10)

確保您的模塊安裝在節點稱為 module.paths 的某個位置,或通過提供絕對路徑來引用該文件.

Make sure you have your module installed somewhere in what node knows as module.paths, or reference the file by providing absolute path.

這篇關于在 Electron 中找不到模塊的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 国产精品伦一区二区三级视频 | 欧美日韩一区在线观看 | 精品欧美视频 | 欧美成人h版在线观看 | 午夜天堂精品久久久久 | 在线观看视频福利 | 国产精品日韩欧美一区二区三区 | 免费观看的黄色网址 | 亚洲天堂中文字幕 | 狠狠干狠狠插 | 久久精品屋 | 欧美aⅴ | 中文精品视频 | 毛片视频免费观看 | h视频免费观看 | 亚洲精品乱码久久久久久黑人 | 喷水毛片| 拍真实国产伦偷精品 | 欧美 日韩 综合 | 99在线免费观看 | 日韩电影免费在线观看中文字幕 | 日本一区二区高清不卡 | 欧美激情综合 | 欧美成人精品一区二区男人看 | 美美女高清毛片视频免费观看 | 国产精品久久久久无码av | 国产1区2区3区 | 亚洲欧美激情国产综合久久久 | 精品久久99 | 成人免费看黄网站在线观看 | 国产精品久久久久国产a级 欧美日本韩国一区二区 | 一级看片| 中文字幕一区在线观看视频 | 中文字幕一区二区三区日韩精品 | 国产精品久久久久久婷婷天堂 | 欧美日韩在线一区二区 | 在线视频中文字幕 | cao在线 | 成人免费一区二区三区牛牛 | 色一级片 | 中文字幕精品一区久久久久 |