gpt4 book ai didi

javascript - npm install 不会创建 dist 文件夹

转载 作者:数据小太阳 更新时间:2023-10-29 06:00:36 26 4
gpt4 key购买 nike

我正在学习本教程 link创建一个 grafana 插件。

但是当我复制这段代码时 link从教程到我的测试服务器(没有 dist/ 文件夹)并运行 npm install npm 不会创建新的 dist/ 文件夹它会创建一个 node_modules 文件夹。

我是不是漏掉了一步,还是理解有误?因为我希望该命令从 src/ 文件夹中的文件中创建一个 dist/ 文件夹?

grunt 文件:

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:

{
"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 && grunt

关于javascript - npm install 不会创建 dist 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37975500/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com