安装NODE JS时出现此错误

时间:2018-01-12 07:28:14

标签: node.js linux mint

我正在尝试按此

安装
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/opt/mean/node_modules/node-sass/build'
gyp ERR! System Linux 4.8.0-53-generic
gyp ERR! command "/usr/bin/node" "/opt/mean/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /opt/mean/node_modules/node-sass
gyp ERR! node -v v9.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
Build failed with error code: 1
npm WARN eslint-config-airbnb@6.0.2 requires a peer of eslint@^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-airbnb@6.0.2 requires a peer of eslint-plugin-react@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.5.3 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.5.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ranjit/.npm/_logs/2018-01-12T07_23_24_314Z-debug.lo

出现此错误

    $(document).ready(function(){

  // On page load: datatable
  var table_document = $('#table_document').dataTable({
    "ajax": "data.php?document=get_document",
    "columns": [
      { "data": "date" },
      { "data": "program",   "sClass": "program" },
      { "data": "doc_type","sClass":"varchar" },
      { "data": "doc_title",        "sClass": "integer" },
      { "data": "recieved",    "sClass": "integer" },
      { "data": "date_recieved",      "sClass": "integer" },
      { "data": "remarks",     "sClass": "integer" },
      { "data": "headquarters" },
      { "data": "functions",      "sClass": "functions" }
    ],
    "aoColumnDefs": [
      { "bSortable": false, "aTargets": [-1] }
    ],
    "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
    "oLanguage": {
      "oPaginate": {
        "sFirst":       " ",
        "sPrevious":    " ",
        "sNext":        " ",
        "sLast":        " ",
      },
      "sLengthMenu":    "Records per page: _MENU_",
      "sInfo":          "Total of _TOTAL_ records (showing _START_ to _END_)",
      "sInfoFiltered":  "(filtered from _MAX_ total records)"
    }
  });

  // On page load: form validation
  jQuery.validator.setDefaults({
    success: 'valid',
    rules: {
      recieved: {
        required: true,
        min:      2000,
        max:      2025
      }
    },
    errorPlacement: function(error, element){
      error.insertBefore(element);
    },
    highlight: function(element){
      $(element).parent('.field_container').removeClass('valid').addClass('error');
    },
    unhighlight: function(element){
      $(element).parent('.field_container').addClass('valid').removeClass('error');
    }
  });
  var form_document = $('#form_document');
  form_document.validate();

  // Show message
  function show_message(message_text, message_type){
    $('#message').html('<p>' + message_text + '</p>').attr('class', message_type);
    $('#message_container').show();
    if (typeof timeout_message !== 'undefined'){
      window.clearTimeout(timeout_message);
    }
    timeout_message = setTimeout(function(){
      hide_message();
    }, 8000);
  }
  // Hide message
  function hide_message(){
    $('#message').html('').attr('class', '');
    $('#message_container').hide();
  }

  // Show loading message
  function show_loading_message(){
    $('#loading_container').show();
  }
  // Hide loading message
  function hide_loading_message(){
    $('#loading_container').hide();
  }

  // Show lightbox
  function show_lightbox(){
    $('.lightbox_bg').show();
    $('.lightbox_container').show();
  }
  // Hide lightbox
  function hide_lightbox(){
    $('.lightbox_bg').hide();
    $('.lightbox_container').hide();
  }
  // Lightbox background
  $(document).on('click', '.lightbox_bg', function(){
    hide_lightbox();
  });
  // Lightbox close button
  $(document).on('click', '.lightbox_close', function(){
    hide_lightbox();
  });
  // Escape keyboard key
  $(document).keyup(function(e){
    if (e.keyCode == 27){
      hide_lightbox();
    }
  });

  // Hide iPad keyboard
  function hide_ipad_keyboard(){
    document.activeElement.blur();
    $('input').blur();
  }

  // Add document button
  $(document).on('click', '#add_Document', function(e){
    e.preventDefault();
    $('.lightbox_content h2').text('Add Document');
    $('#form_document button').text('Add Document');
    $('#form_document').attr('class', 'form add');
    $('#form_document').attr('data-id', '');
    $('#form_document .field_container label.error').hide();
    $('#form_document .field_container').removeClass('valid').removeClass('error');
    $('#form_document #date').val('');
    $('#form_document #program').val('');
    $('#form_document #doc_type').val('');
    $('#form_document #doc_title').val('');
    $('#form_document #recieved').val('');
    $('#form_document #date_recieved').val('');
    $('#form_document #remarks').val('');

    show_lightbox();
  });

  // Add document submit form
  $(document).on('submit', '#form_document.add', function(e){
    e.preventDefault();
    // Validate form
    if (form_document.valid() == true){
      // Send document information to database
      hide_ipad_keyboard();
      hide_lightbox();
      show_loading_message();
      var form_data = $('#form_document').serialize();
      var request   = $.ajax({
        url:          'data.php?document=add_document',
        cache:        false,
        data:         form_data,
        dataType:     'json',
        contentType:  'application/json; charset=utf-8',
        type:         'get'
      });
      request.done(function(output){
        if (output.result == 'success'){
          // Reload datable
          table_document.api().ajax.reload(function(){
            hide_loading_message();
            var program = $('#program').val();
            show_message("program '" + program + "' added successfully.", 'success');
          }, true);
        } else {
          hide_loading_message();
          show_message('Add request failed', 'error');
        }
      });
      request.fail(function(jqXHR, textStatus){
        hide_loading_message();
        show_message('Add request failed: ' + textStatus, 'error');
      });
    }
  });

  // Edit document button
  $(document).on('click', '.function_edit a', function(e){
    e.preventDefault();
    // Get document information from database
    show_loading_message();
    var doc_id      = $(this).data('doc_id');
    var request = $.ajax({
      url:          'data.php?document=get_document',
      cache:        false,
      data:         'doc_id=' + doc_id,
      dataType:     'json',
      contentType:  'application/json; charset=utf-8',
      type:         'get'
    });
    request.done(function(output){
      if (output.result == 'success'){
        $('.lightbox_content h2').text('Edit document');
        $('#form_documentbutton').text('Edit document');
        $('#form_document').attr('class', 'form edit');
        $('#form_document').attr('data-id', id);
        $('#form_document .field_container label.error').hide();
        $('#form_document .field_container').removeClass('valid').removeClass('error');
        $('#form_document #date').val(output.data[0].date);
        $('#form_document #program').val(output.data[0].program);
        $('#form_document #doc_type').val(output.data[0].doc_type);
        $('#form_document #doc_title').val(output.data[0].doc_title);
        $('#form_document #recieved').val(output.data[0].recieved);
        $('#form_document #date_recieved').val(output.data[0].date_recieved);
        $('#form_document #remarks').val(output.data[0].remaks);
        hide_loading_message();
        show_lightbox();
      } else {
        hide_loading_message();
        show_message('Information request failed', 'error');
      }
    });
    request.fail(function(jqXHR, textStatus){
      hide_loading_message();
      show_message('Information request failed: ' + textStatus, 'error');
    });
  });

  // Edit document submit form
  $(document).on('submit', '#form_document.edit', function(e){
    e.preventDefault();
    // Validate form
    if (form_document.valid() == true){
      // Send document information to database
      hide_ipad_keyboard();
      hide_lightbox();
      show_loading_message();
      var id        = $('#form_document').attr('data-id');
      var form_data = $('#form_document').serialize();
      var request   = $.ajax({
        url:          'data.php?document=edit_document&doc_id=' + doc_id,
        cache:        false,
        data:         form_data,
        dataType:     'json',
        contentType:  'application/json; charset=utf-8',
        type:         'get'
      });
      request.done(function(output){
        if (output.result == 'success'){
          // Reload datable
          table_document.api().ajax.reload(function(){
            hide_loading_message();
            var doc_title = $('#doc_title').val();
            show_message("document '" + doc_title + "' edited successfully.", 'success');
          }, true);
        } else {
          hide_loading_message();
          show_message('Edit request failed', 'error');
        }
      });
      request.fail(function(jqXHR, textStatus){
        hide_loading_message();
        show_message('Edit request failed: ' + textStatus, 'error');
      });
    }
  });

  // Delete document
  $(document).on('click', '.function_delete a', function(e){
    e.preventDefault();
    var doc_title = $(this).data('name');
    if (confirm("Are you sure you want to delete '" + doc_title + "'?")){
      show_loading_message();
      var id      = $(this).data('id');
      var request = $.ajax({
        url:          'data.php?document=delete_document&id=' + id,
        cache:        false,
        dataType:     'json',
        contentType:  'application/json; charset=utf-8',
        type:         'get'
      });
      request.done(function(output){
        if (output.result == 'success'){
          // Reload datable
          table_document.api().ajax.reload(function(){
            hide_loading_message();
            show_message("document '" + doc_title + "' deleted successfully.", 'success');
          }, true);
        } else {
          hide_loading_message();
          show_message('Delete request failed', 'error');
        }
      });
      request.fail(function(jqXHR, textStatus){
        hide_loading_message();
        show_message('Delete request failed: ' + textStatus, 'error');
      });
    }
  });
});

我也获得了许可。但对我没用。

来源 - https://www.digitalocean.com/community/tutorials/how-to-install-a-mean-js-stack-on-an-ubuntu-14-04-server

1 个答案:

答案 0 :(得分:0)

尝试使用此命令sudo -i以root用户身份登录。