0

J'ai un problème pour déployer mon application hello world reactjs sur beanstalk. Je le fais quand je veux l'exécuter manuellement: 1) npm commencersh: webpack: erreur de commande introuvable lors du téléchargement de mon projet hello world reactjs sur beanstalk

puis le projet est construit et copié sur le dossier dist et cela fonctionne. Voici ma section de script package.json:

"scripts": { 
"start": "npm run build && node server", 
"build": "node_modules/.bin/webpack -d && xcopy \"src/index.html\" \"dist/index.html\" /F /Y" 
} 

Quand je Déployez le projet sur beanstalk je reçois l'erreur suivante:

sh: webpack: command not found 

également une pile complète d'erreur est ajouté à la fin de cette poster pour plus de détails. J'ai beaucoup cherché et il semble que ce soit le problème de la configuration globale de webpack. J'ai donc utilisé preinstall pour configurer globalement webpack mais pas de résultat. Toute idée ou toute aide est appréciée

erreur de pile complète:

------------------------------------- 
/var/log/nodejs/nodejs.log 
------------------------------------- 
npm ERR! 
npm ERR! Failed at the [email protected] build script 'webpack -d && 
xcopy "src/index.html" "dist/index.html" /F /Y'. 
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 reactjs-basics 
    package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  webpack -d && xcopy "src/index.html" "dist/index.html" /F /Y 
npm ERR! You can get information on how to open an issue for this project 
with: 
    npm ERR!  npm bugs reactjs-basics 
    npm ERR! Or if that isn't available, you can get their info via: 
    npm ERR!  npm owner ls reactjs-basics 
    npm ERR! There is likely additional logging output above. 

    npm ERR! Please include the following file with any support request: 
    npm ERR!  /var/app/current/npm-debug.log 

    npm ERR! Linux 4.9.32-15.41.amzn1.x86_64 
    npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.11.1-linux- 
    x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.11.1-linux- 
x64/bin/npm" "start" 
npm ERR! node v6.11.1 
npm ERR! npm v3.10.10 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `npm run build && node server` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'npm run build && 
node server'. 
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 reactjs-basics 
    package, 
    npm ERR! not with npm itself. 
    npm ERR! Tell the author that this fails on your system: 
    npm ERR!  npm run build && node server 
    npm ERR! You can get information on how to open an issue for this project 
    with: 
    npm ERR!  npm bugs reactjs-basics 
    npm ERR! Or if that isn't available, you can get their info via: 
    npm ERR!  npm owner ls reactjs-basics 
    npm ERR! There is likely additional logging output above. 

    npm ERR! Please include the following file with any support request: 
    npm ERR!  /var/app/current/npm-debug.log 

    > [email protected] start /var/app/current 
    > npm run build && node server 


     > [email protected] build /var/app/current 
      > webpack -d && xcopy "src/index.html" "dist/index.html" /F /Y 

      sh: webpack: command not found 

Mise à jour: Mes dépendances et les dépendances de dev sont les suivantes:

"dependencies": { 
    "react": "^15.4.1", 
    "react-dom": "^15.4.1", 
    "react-router": "^3.0.0", 
    "classnames": "^2.2.5", 
    "concurrently": "^3.5.0", 
    "express": "^4.14.0", 
    "morgan": "^1.7.0", 
    "react-scripts": "0.2.1" 
    }, 
    "devDependencies": { 
    "babel-core": "^6.20.0", 
    "babel-jest": "^19.0.0", 
    "babel-loader": "^6.2.9", 
    "babel-preset-es2015": "^6.18.0", 
    "babel-preset-react": "^6.16.0", 
    "babel-preset-stage-0": "^6.16.0", 
    "babel-preset-stage-2": "^6.18.0", 
    "chai": "^3.5.0", 
    "chai-jquery": "^2.0.0", 
    "gulp": "^3.9.1", 
    "gulp-load-plugins": "^1.4.0", 
    "gulp-open": "^2.0.0", 
    "ignore-styles": "^5.0.1", 
    "webpack": "^1.14.0", 
    "webpack-dev-server": "^1.16.2", 
     "react-scripts": "0.2.1" 
    } 
+0

il semble que vous n'avez pas 'webpack' installé. est-ce sur 'devDependencies'? Est-ce que vous installez 'devDependencies' dans' production'? alors, vous n'avez pas besoin de pointer sur le chemin si vous exécutez le script via npm, changez 'node_modules/.bin/webpack' en' webpack' – Hitmands

+0

Merci @Hitmands en fait j'ai webpack dans les dépendances pas sur les dépendances lui-même. Je l'ai essayé sans node_modules/.bin/et cela n'a pas fonctionné aussi bien. Pensez-vous que je devrais ajouter le webpack dans les dépendances? –

+0

J'ai également mis à jour mon post avec les dépendances et dev-dépendances de mon package.json –

Répondre

0

J'ai trouvé le problème:

Le problème est mon fichier script donc au lieu de

"build": "node_modules/.bin/webpack -d && xcopy \"src/index.html\" \"dist/index.html\" /F /Y" 

devrait être

webpack -d && cp src/index.html dist/index.html