[英]npm install doesnt create dist folder
I am following this tutorial link to create a grafana plugin.我正在按照本教程链接创建一个 grafana 插件。
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.但是,当我将此代码链接从教程复制到我的测试服务器(没有dist/
文件夹)并运行npm install
npm 时,它不会创建新的dist/
文件夹,而是创建一个node_modules
文件夹。
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?因为我希望该命令从src/
文件夹中的文件中创建一个dist/
文件夹?
The grunt file:咕噜文件:
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']);
};
The package.json: 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"
}
}
You are missing running grunt
default task您缺少运行grunt
默认任务
You should run:你应该运行:
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
(将 src 文件复制到 dist,如您在 Gruntfile.js copy:src_to_dist
任务中copy:src_to_dist
)
So in short just run: $ npm install && grunt
所以简而言之,只需运行: $ npm install && grunt
npm install
command installs packages that your project will be using as dependencies. npm install
命令安装您的项目将用作依赖项的包。 It will create the node_modules
directory in your current directory (if one doesn't exist yet), and will download the package to that directory.它将在您的当前目录中创建node_modules
目录(如果尚不存在),并将包下载到该目录。
Actually, running an npm install
will also execute the prepublish
of your package.json
if there is one.实际上,运行npm install
也会执行package.json
的prepublish
(如果有的话)。
For your needs, it sounds like you want to do this:根据您的需要,听起来您想要这样做:
"scripts": {
"build": "grunt",
"prepublish": "npm run build"
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.