Reputation: 53
I've looked several Q&A with people experiencing the same problem, but I still can't find what it wrong in my code.
No bundle.js file get created when running: sudo npm run build **
Here is my code:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Cocinando Con Lalinde</title>
</head>
<body>
<div id="app"></div>
<script src="index.js"></script>
</body>
</html>
package.json
{
"name": "Cocinando-con-Lalinde",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --hot",
"build": "webpack"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"styled-components": "^2.4.0"
},
"devDependencies": {
"babel-preset-env": "^1.6.1",
"json-loader": "^0.5.7",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.3"
}
}
webpack.config.js
var config = {
entry: './main.js',
output: {
path:'/',
filename: 'bundle.js'
},
devServer: {
inline: true,
port: 8080
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
}
]
}
}
module.exports = config;
I tried several tips and nothing works, bundle.js is not created.
Does someone has an clue about it?
** By the way, access permission denied when running npm run build, here's what I got:
Error: EACCES: permission denied, open '/bundle.js' at Error (native)
Does someone know why?
Upvotes: 5
Views: 8786
Reputation: 927
You're setting path to '/' which is relative to your systems file structure. You're likely generating the bundle file in your home directory.
This also explains the access denied because you wouldn't have write permissions to your root folder in Mac or linux without sudo
Change path to
path: __dirname + '/dist'
or some other folder you might want to use.
Upvotes: 7