admin管理员组文章数量:1356862
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-ponents": "^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?
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-ponents": "^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?
Share Improve this question asked Jan 10, 2018 at 18:23 mepolpmepolp 531 silver badge3 bronze badges 1
- If the answer I posted below works for you please mark it accepted. Thank you! – Joshua Underwood Commented Jan 11, 2018 at 1:47
1 Answer
Reset to default 7You'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.
本文标签: javascriptnpm run build gt bundlejs not getting createdStack Overflow
版权声明:本文标题:javascript - npm run build > bundle.js not getting created - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743951762a2567420.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论