2015-06-25 199 views
6

您好我從運行的Node.js服務器下載我的項目的副本,並嘗試運行,但遇到了以下錯誤:Node.js的錯誤:%1不是有效的Win32應用程序

錯誤:

E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\bcrypt\node_modules\bindings\bindings.js:79 
     throw e 
      ^
Error: %1 is not a valid Win32 application. 
E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\bcrypt\build\Release\bcrypt_lib.node 
    at Error (native) 
    at Module.load (module.js:355:32) 
    at Function.Module._load (module.js:310:12) 
    at Module.require (module.js:365:17) 
    at require (module.js:384:17) 
    at bindings (E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\bcrypt\node_modules\bindings\bindings.js:74:15) 
    at Object.<anonymous> (E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\bcrypt\bcrypt.js:3:35) 
    at Module._compile (module.js:460:26) 
    at Object.Module._extensions..js (module.js:478:10) 
    at Module.load (module.js:355:32) 
    at Function.Module._load (module.js:310:12) 
    at Module.require (module.js:365:17) 
    at require (module.js:384:17) 
    at Object.<anonymous> (E:\Projects\Smart Automation Web\Zigma_copy\automator\api\services\UserManager.js:2:14) 
    at Module._compile (module.js:460:26) 
    at Object.Module._extensions..js (module.js:478:10) 

我如何試圖運行我的應用程序:

  1. 我使用FTP
  2. 我通過webst開盤項目下載完整的app文件夾從我的服務器orm IDE
  3. 我打開它的終端並輸入:npm install
  4. 它是成功的。
  5. 然後我輸入帆升降機,並得到以下錯誤。

我是新手,無法找到失敗的原因。雖然我可以閱讀這個錯誤,但它說了一些關於我的UserManager.js的內容,所以我也在這裏討論它。

UserManager.js:

var jwt = require('jsonwebtoken') 
var bcrypt = require('bcrypt'); 

var jwtSecret = "werisdkf120sdkfr84rwerf"; 
var ISSUER = "home-automator.com"; 
var EXPIRY_TIME = 120*500; 

function genToken(user) { 
    var token = jwt.sign({id: user.id}, jwtSecret, {issuer: ISSUER, expiresInMinutes: EXPIRY_TIME}); 
    return token; 
} 

module.exports = { 
    hashPassword: function (plainTxtPassword, salt, next) { 
    salt = salt || bcrypt.genSaltSync(6); 
    bcrypt.hash(plainTxtPassword, salt, function (err, hash) { 
     if (err) { 
     return next({err: {message: "Something went wrong. Please try again later."}}); 
     } 
     next(null, hash, salt); 
    }) 
    }, 

    createUser: function (newUser, next) { 
    User.findOneByEmail(newUser.email, function (err, user) { 
     if (err) { 
     return next({err: {message: "Failed to create user. Please try again later."}}); 
     } 

     if (user) { 
     return next({err: {message: "Email already registered. Please try a different email address."}}) 
     } 

     User.create(newUser, function (err, user) { 
     if (err) { 
      return next({err: err}); 
     } 

     next(null, user); 
     }) 
    }) 
    }, 

    generateAuthToken: function (user) { 
    return genToken(user); 
    }, 

    generateAuthTokenFromPassword: function (username, password, next) { 
    User.findOne({email: username}, function (err, user) { 
     if (err) { 
     return next({err: {message: "Something went wrong, please try again later."}}); 
     } 

     if (!user) { 
     return next({err: {message: "Invalid email address and/or password. Please enter valid login credentials and try again."}}) 
     } 

     bcrypt.compare(password, user.encrypted_password, function (err, valid) { 
     if (err) { 
      return next({err: {message: "Something went wrong, please try again later."}}); 
     } 
     if (!valid) { 
      return next({err: {message: "Invalid email address and/or password. Please try again with valid login credentials."}}); 
     } 
     else { 
      next(null, user, genToken(user)); 
     } 
     }) 
    }) 
    }, 

    getUserFromAuthToken: function (token, next) { 
    jwt.verify(token, jwtSecret, {issuer: ISSUER}, function (err, user) { 
     if (err) { 
     return next(err); 
     } 

     User.findOne({id: user.id}, function (err, userData) { 
     if (err) next(err); 
     return next(null, userData); 
     }) 
    }) 
    } 
} 

這是我刪除node_modules和做NPM重新安裝後得到。另外現在看起來一些包丟失了,因爲錯誤的:

E:\Projects\Smart Automation Web\Zigma_copy\automator>npm install 
npm WARN deprecated [email protected]: Critical vulnerability fix in v5.0.0. See https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/ 
npm WARN deprecated [email protected]: DEPRECATED. See readme: https://github.com/gruntjs/grunt-lib-contrib 
npm WARN deprecated [email protected]: Security update: Versions below 3.0.0 are deprecated. 
/


> [email protected] install E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\bcrypt 
> node-gyp rebuild 


E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\bcrypt>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. 
gyp ERR! stack  at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14) 
gyp ERR! stack  at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11 
gyp ERR! stack  at FSReqWrap.oncomplete (evalmachine.<anonymous>:99:15) 
gyp ERR! System Windows_NT 6.3.9600 
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" 
gyp ERR! cwd E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\bcrypt 
gyp ERR! node -v v0.12.0 
gyp ERR! node-gyp -v v1.0.2 
ERR! not ok 
- 


> [email protected] preinstall E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails 
> node ./lib/preinstall_npmcheck.js 

Sails.js Installation: Checking npm-version successful 
\ 


> [email protected] install E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails-mongo\node_modules\mongodb\node_modules\kerberos 
> (node-gyp rebuild 2> builderror.log) || (exit 0) 


E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails-mongo\node_modules\mongodb\node_modules\kerberos>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
/


> [email protected] install E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails-mongo\node_modules\mongodb\node_modules\bson 
> (node-gyp rebuild 2> builderror.log) || (exit 0) 


E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails-mongo\node_modules\mongodb\node_modules\bson>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
- 


> [email protected] install E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails\node_modules\sails-hook-sockets\node_modules\socket.io\node_modules\engine.io\node_modules\ws 
> (node-gyp rebuild 2> builderror.log) || (exit 0) 

\ 
E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails\node_modules\sails-hook-sockets\node_modules\socket.io\node_modules\engine.io\node_modules\ws>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo 
dules\node-gyp\bin\node-gyp.js" rebuild 
- 
> [email protected] install E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails\node_modules\sails-hook-sockets\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws 
> (node-gyp rebuild 2> builderror.log) || (exit 0) 


E:\Projects\Smart Automation Web\Zigma_copy\automator\node_modules\sails\node_modules\sails-hook-sockets\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\ 
\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
npm ERR! Windows_NT 6.3.9600 
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" 
npm ERR! node v0.12.0 
npm ERR! npm v2.5.1 
npm ERR! code ELIFECYCLE 

npm ERR! [email protected] install: `node-gyp rebuild` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'. 
npm ERR! This is most likely a problem with the bcrypt package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node-gyp rebuild 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls bcrypt 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  E:\Projects\Smart Automation Web\Zigma_copy\automator\npm-debug.log 
+0

如果您下載了完整的應用程序文件夾,這意味着您還下載了'node_modules'文件夾。因此,'npm install'會報告成功(當然),但已安裝的模塊,特別是原生模塊,已經針對目標機器進行了編譯。刪除該文件夾並在主機上再次安裝依賴關係。 –

+0

@RobertRossmann:所以你的意思是,我應該刪除我的這個應用程序的node_modules文件夾並在終端中再次運行npm install? – Rahul

+0

是的。我總是建議在應用程序移動到另一個操作系統時重新創建'node_modules'。 –

回答

5

我有這個錯誤試圖在Windows部署過。

在項目文件夾node_modules(..programs \ server \ node_modules)中的部署服務器上刪除包含npm-bcrypt的文件夾。

在部署服務器,運行:

npm install bcrypt 

它將重新安裝bcrypt應該解決的錯誤你。另外,您將需要Python> 2.5和< 3.0才能正確處理光纖。如果您安裝最新版本,它可能無法正常工作。

相關問題