npm install不会创建dist文件夹 [英] npm install doesnt create dist folder

查看:584
本文介绍了npm install不会创建dist文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照本教程链接链接至创建一个grafana插件.

I am following this tutorial link to create a grafana plugin.

但是当我将此代码从教程中复制链接到我的测试中时服务器(没有dist/文件夹)并运行npm install npm不会创建新的dist/文件夹,而是创建一个node_modules文件夹.

But when I copy this code link from the tutorial to my test server(without the dist/ folder) and run npm install npm doesn’t create a new dist/ folder instead it creates a node_modules folder.

我在这里错过了一步吗,还是我理解不正确的地方?因为我希望该命令从src/文件夹中的文件中创建一个dist/文件夹?

Am I missing a step here or am I understanding something incorrect? Since I expected that command to create a dist/ folder out of the files in the src/ folder?

咕unt声文件:

module.exports = (grunt) => {
  require('load-grunt-tasks')(grunt);

  grunt.loadNpmTasks('grunt-execute');
  grunt.loadNpmTasks('grunt-contrib-clean');

  grunt.initConfig({

    clean: ['dist'],

    copy: {
      src_to_dist: {
        cwd: 'src',
        expand: true,
        src: ['**/*', '!**/*.js', '!**/*.scss'],
        dest: 'dist'
      },
      pluginDef: {
        expand: true,
        src: [ 'plugin.json', 'README.md' ],
        dest: 'dist',
      }
    },

    watch: {
      rebuild_all: {
        files: ['src/**/*', 'plugin.json'],
        tasks: ['default'],
        options: {spawn: false}
      },
    },

    babel: {
      options: {
        sourceMap: true,
        presets: ['es2015'],
        plugins: ['transform-es2015-modules-systemjs', 'transform-es2015-for-of'],
      },
      dist: {
        files: [{
          cwd: 'src',
          expand: true,
          src: ['*.js'],
          dest: 'dist',
          ext: '.js'
        }]
      },
    },

  });

  grunt.registerTask('default', ['clean', 'copy:src_to_dist', 'copy:pluginDef', 'babel']);
};

package.json:

The package.json:

{
  "name": "clock-panel",
  "version": "1.0.0",
  "description": "Clock Panel Plugin for Grafana",
  "main": "src/module.js",
  "scripts": {
    "lint": "eslint --color .",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "clock",
    "grafana",
    "plugin",
    "panel"
  ],
  "author": "Raintank",
  "license": "MIT",
  "devDependencies": {
    "babel": "~6.5.1",
    "babel-eslint": "^6.0.0",
    "babel-plugin-transform-es2015-modules-systemjs": "^6.5.0",
    "babel-preset-es2015": "^6.5.0",
    "eslint": "^2.5.1",
    "eslint-config-airbnb": "^6.2.0",
    "eslint-plugin-import": "^1.4.0",
    "grunt": "~0.4.5",
    "grunt-babel": "~6.0.0",
    "grunt-contrib-clean": "~0.6.0",
    "grunt-contrib-copy": "~0.8.2",
    "grunt-contrib-uglify": "~0.11.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-execute": "~0.2.2",
    "grunt-systemjs-builder": "^0.2.5",
    "load-grunt-tasks": "~3.2.0"
  },
  "dependencies": {
    "lodash": "~4.0.0",
    "moment": "^2.12.0"
  }
}

推荐答案

您缺少运行grunt默认任务

您应该运行:

npm install(将安装依赖项),然后是grunt(将src文件复制到dist,如在Gruntfile.js copy:src_to_dist任务中看到的那样)

npm install (which installs your dependencies), followed by a grunt (which copies src files to dist as you can see in the Gruntfile.js copy:src_to_dist task)

因此简而言之,只需运行:$ npm install && grunt

So in short just run: $ npm install && grunt

这篇关于npm install不会创建dist文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆