Node.js Electron和Webpack eNot:无此类文件或目录,打开'/path.txt';
我是一个尝试使用Electron(以前是Atom)和Reactjs与Webpack捆绑的初学者。在我尝试使用Electron的远程模块访问React组件中的主窗口之前,一切正常Node.js Electron和Webpack eNot:无此类文件或目录,打开'/path.txt';,node.js,reactjs,webpack,electron,Node.js,Reactjs,Webpack,Electron,我是一个尝试使用Electron(以前是Atom)和Reactjs与Webpack捆绑的初学者。在我尝试使用Electron的远程模块访问React组件中的主窗口之前,一切正常 尝试导入此模块时,出现了一个臭名昭著的错误: Uncaught错误:enoint:没有这样的文件或目录,请打开“/path.txt” 我尝试重新安装了electron,检查了node_modules/electron,发现path.txt就在那里 这是我的webpack.config.js: var webpack =
尝试导入此模块时,出现了一个臭名昭著的错误:
Uncaught错误:enoint:没有这样的文件或目录,请打开“/path.txt”
我尝试重新安装了electron,检查了node_modules/electron,发现path.txt就在那里
这是我的webpack.config.js:
var webpack = require('webpack');
module.exports = {
context: __dirname,
entry: {
app: ['webpack/hot/dev-server', './src/App.jsx'],
},
target: 'node',
output: {
path: './public/built',
filename: 'bundle.js',
publicPath: 'http://localhost:8080/built/'
},
devServer: {
contentBase: './public',
publicPath: 'http://localhost:8080/built/'
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
include: /src/,
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.(png|jpg)$/,
loader: 'file-loader?name=[path][name].[hash].[ext]'
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
}
这是我的package.json:
{
"name": "app",
"version": "0.1.0",
"main": "main.js",
"description": "description",
"license": "UNLICENSED",
"repository": {
"type": "git",
"url": "https://github.com"
},
"scripts": {
"start": "./node_modules/.bin/electron .",
"watch": "./node_modules/.bin/webpack-dev-server"
},
"dependencies": {
"electron": "^1.3.5",
"radium": "^0.17.1",
"react": "^15.0.1",
"react-dom": "^15.0.1"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.7.7",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"css-loader": "^0.24.0",
"file-loader": "^0.9.0",
"style-loader": "^0.13.1",
"webpack": "^1.13.0",
"webpack-dev-server": "^1.14.1"
}
}
我怀疑它可能与package.json中的启动脚本有关,因为path.txt与node_modules/.bin/electron不在同一目录中。不过,我还没有找到解决方法。如果还不晚,您只需在webpack.config.js中将“节点”目标替换为“电子渲染器”只需运行如下命令即可
cd node_modules/electron && node install.js
dist/Electron.app/Contents/MacOS/Electron
它将创建path.txt文件
对于Mac,该文件包含如下内容
cd node_modules/electron && node install.js
dist/Electron.app/Contents/MacOS/Electron
对于搜索此项的用户,完全没有帮助的Windows症状在D:\path.txt上是不存在的