DWQA QuestionsCategory: Servernode app.js Error% 1 is not a valid Win32 Application
Futurefinger asked 1 month ago

There is a project in clone on GitHub.
Project address:https://github.com/cnBruceHong/weibo-nodejs
Errors are reported as follows:

F:\weibo-nodejs (master) ([email protected])
λ node app
F:\weibo-nodejs\node_modules\bcrypt\node_modules\bindings\bindings.js:83
        throw e
        ^

Error: %1 is not a valid Win32 application.
\?\F:\weibo-nodejs\node_modules\bcrypt\build\Release\bcrypt_lib.node
    at Error (native)
    at Object.Module._extensions..node (module.js:434:18)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at bindings (F:\weibo-nodejs\node_modules\bcrypt\node_modules\bindings\bindings.js:76:44)
    at Object.<anonymous> (F:\weibo-nodejs\node_modules\bcrypt\bcrypt.js:3:35)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

The node client is changed to 64 bit, but it still has no effect.

app.js:

var express = require('express');
var http = require('http');
var path = require('path');
var favicon = require('static-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var routes = require('./routes');
var users = require('./routes/user');
Var register = require ('/ routes / Register'); // introduces routing logic
var messages = require('./lib/messages');
var login = require('./routes/login');
var user = require('./lib/middleware/user');
var entries = require('./routes/entries');
var validate = require('./lib/middleware/validate');
var page = require('./lib/middleware/page');
var Entry = require('./lib/entry');
var api = require('./routes/api');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

app.use(favicon());
app.use(logger('dev'));
app.use(express.methodOverride());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(express.cookieParser('bruce'));
app.use(cookieParser());
app.use(express.session());
app.use('/api', api.auth);
app.use (user); // add middleware to the program
app.use(messages);
app.use(express.static(path.join(__dirname, 'public')));
app.use(app.router);
app.use(routes.notfound);
app.use(routes.error);

app.get('/', page(Entry.count, 5), entries.list);
app.get('/register', register.form);
app.post('/register', register.submit);
app.get('/login', login.form);
app.post('/login', login.submit);
app.get('/logout', login.logout);
app.get('/post', entries.form);
app.post('/post',
    validate.required('entry[title]'),
    validate.lengthAbove('entry[title]', 4),
    entries.submit
);
app.get('/api/user/:id', api.user);
//app.get('/api/entries/:page?', api.entries);
app.post('/api/entry',
    validate.required('entry[title]'),
    validate.lengthAbove('entry[title]', 4),
    entries.submit
);
app.get('/api/entries/:page?', page(Entry.count, 5), api.entries);


/// catch 404 and forwarding to error handler
app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
});

/// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
        res.render('error', {
            message: err.message,
            error: err
        });
    });
}

if (process.env.ERROR_ROUTE) {
    app.get('/dev/error', function(req, res, next){
        var err = new Error('database connection failed');
        err.type = 'database';
        next(err);
    });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
    res.render('error', {
        message: err.message,
        error: {}
    });
});

module.exports = app;
kavinwang replied 1 month ago

Does bcrypt not support windows?

2 Answers
rickytan answered 1 month ago
node ./bin/www
Poets depend on the moon answered 1 month ago

Have you solved your problem? I have encountered it, too