没有“构建"运行npm run deploy时找到的文件夹 [英] No "build" folder found when running npm run deploy
问题描述
我正在尝试将我的react应用程序部署到github页面.每次我运行"npm run deploy"时,都会出现此错误:
I am trying to deploy my react app to github pages. Every time I run "npm run deploy" I get this error:
ENOENT: no such file or directory, stat '/Users/username/my-app/build'
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! reactdemo@1.0.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactdemo@1.0.0 deploy script 'gh-pages -d build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the reactdemo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! gh-pages -d build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs reactdemo
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls reactdemo
npm ERR! There is likely additional logging output above.
这是我的package.json脚本
Here are my package.json scripts
"scripts": {
"compile": "webpack",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --config webpack.config.js",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
Webpack.config.js
Webpack.config.js
const path = require('path');
module.exports = {
context: path.join(__dirname, 'src'),
entry: [
'./main.js',
],
output: {
path: path.join(__dirname, 'www'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
'babel-loader',
],
},
],
},
resolve: {
modules: [
path.join(__dirname, 'node_modules'),
],
},
};
我猜测这与构建脚本的编写方式有关.运行"npm run build"效果很好.
I am guessing that it has something to do with the way my build script is written. Running "npm run build" works fine.
添加了webpack配置
Added webpack config
推荐答案
命令 gh-pages -d build
将部署 build
目录中的所有内容.但是,您的捆绑包不使用 build
目录,而使用 www
目录.
Command gh-pages -d build
will deploy everything from your build
directory. But you don't use build
directory for your bundle, you use www
directory.
将命令更改为 gh-pages -d www
.
这篇关于没有“构建"运行npm run deploy时找到的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!