我正在尝试使用本教程使用 npm 和 gulp 安装语义 UI:http://www.semantic-ui.com/introduction/getting-started.html

我运行 npm install semantic-ui --save 一切正常。
但后来我直接进入 semantic/ 文件夹并运行 gulp build 但它说:

cannot find semantic.json. Run "gulp install" to set-up Semantic
semantic.json 文件位于我的项目的根目录中。我也试过 gulp install 但它说 Task 'install' is not in your gulpfile
我应该怎么办?

编辑:
这是我的 gulpfile.js 文件:
/*******************************
            Set-up
*******************************/

var
  gulp         = require('gulp-help')(require('gulp')),

  // read user config to know what task to load
  config       = require('./tasks/config/user'),

  // watch changes
  watch        = require('./tasks/watch'),

  // build all files
  build        = require('./tasks/build'),
  buildJS      = require('./tasks/build/javascript'),
  buildCSS     = require('./tasks/build/css'),
  buildAssets  = require('./tasks/build/assets'),

  // utility
  clean        = require('./tasks/clean'),
  version      = require('./tasks/version'),

  // docs tasks
  serveDocs    = require('./tasks/docs/serve'),
  buildDocs    = require('./tasks/docs/build'),

  // rtl
  buildRTL     = require('./tasks/rtl/build'),
  watchRTL     = require('./tasks/rtl/watch')
;


/*******************************
             Tasks
*******************************/

gulp.task('default', false, [
  'watch'
]);

gulp.task('watch', 'Watch for site/theme changes', watch);

gulp.task('build', 'Builds all files from source', build);
gulp.task('build-javascript', 'Builds all javascript from source', buildJS);
gulp.task('build-css', 'Builds all css from source', buildCSS);
gulp.task('build-assets', 'Copies all assets from source', buildAssets);

gulp.task('clean', 'Clean dist folder', clean);
gulp.task('version', 'Displays current version of Semantic', version);

/*--------------
      Docs
---------------*/

/*
  Lets you serve files to a local documentation instance
  https://github.com/Semantic-Org/Semantic-UI-Docs/
*/

gulp.task('serve-docs', 'Serve file changes to SUI Docs', serveDocs);
gulp.task('build-docs', 'Build all files and add to SUI Docs', buildDocs);


/*--------------
      RTL
---------------*/

if(config.rtl) {
  gulp.task('watch-rtl', 'Build all files as RTL', watchRTL);
  gulp.task('build-rtl', 'Watch files as RTL ', buildRTL);
}

最佳答案

node_modules 位于上游或不同文件夹时会发生此问题。假设您全局安装 semantic-ui 并且 node_modules 位于:
/Users/afshin/node_modules/
解决此问题所需要做的就是将 node_modules 复制到 semantic-ui 文件夹(您的语义用户界面项目文件夹)

希望这可以使某人免于头痛。

关于node.js - gulp在安装semantic-ui时找不到semantic.json,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31214511/

10-09 22:15