运行gulp的问题:错误:找不到模块' ../ package.json'

时间:2018-03-23 16:40:46

标签: node.js gulp

萨拉姆 我试图在我的项目上运行Gulp,首先我按照以下步骤安装了Gulp: npm install gulp-cli -g npm install gulp -D 节点版本:6.9.1

当我运行gulp时,我遇到了一些依赖性问题我也安装了它们。 最后我遇到了以下问题:

  

错误:找不到模块' ../ package.json'       在Function.Module._resolveFilename(module.js:543:15)       在Function.Module._load(module.js:470:25)       在Module.require(module.js:593:17)       at require(internal / module.js:11:18)       在对象。 (E:\ Dadekavan \ ArNikAPI \ 04-的UserInterface \ ArnikCo.UI \功能\布局\查看\ UI \设计\ node_modules \一饮而尽,sourcemaps的\ src \ utils.js:9:19)       在Module._compile(module.js:649:30)       at Object.Module._extensions..js(module.js:660:10)       在Module.load(module.js:561:32)       在tryModuleLoad(module.js:501:12)       在Function.Module._load(module.js:493:3)

我试图完全删除nodeJs并安装node@8.10或node@9.9但我仍然有这个问题!

任何人都可以帮我吗?

更新: 这些是我的package.json和gulpfile.js文件。

gulp package.json

{   "_from": "gulp",   "_id": "gulp@3.9.1",   "_inBundle": false,   "_integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=",   "_location": "/gulp",   "_phantomChildren": {},   "_requested": {
    "type": "tag",
    "registry": true,
    "raw": "gulp",
    "name": "gulp",
    "escapedName": "gulp",
    "rawSpec": "",
    "saveSpec": null,
    "fetchSpec": "latest"   },   "_requiredBy": [
    "#USER"   ],   "_resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz",   "_shasum": "571ce45928dd40af6514fc4011866016c13845b4",   "_spec": "gulp",   "_where": "E:\\Dadekavan\\ArNikAPI\\04-UserInterface\\ArnikCo.UI\\Features\\Layout\\Views\\UI\\Designer", "author": {
    "name": "Fractal",
    "email": "contact@wearefractal.com",
    "url": "http://wearefractal.com/"   },   "bin": {
    "gulp": "./bin/gulp.js"   },   "bugs": {
    "url": "https://github.com/gulpjs/gulp/issues"   },   "bundleDependencies": false,   "dependencies": {
    "archy": "^1.0.0",
    "chalk": "^1.0.0",
    "deprecated": "^0.0.1",
    "gulp-util": "^3.0.0",
    "interpret": "^1.0.0",
    "liftoff": "^2.1.0",
    "minimist": "^1.1.0",
    "orchestrator": "^0.3.0",
    "pretty-hrtime": "^1.0.0",
    "semver": "^4.1.0",
    "tildify": "^1.0.0",
    "v8flags": "^2.0.2",
    "vinyl-fs": "^0.3.0"   },   "deprecated": false,   "description": "The streaming build system",   "devDependencies": {
    "coveralls": "^2.7.0",
    "eslint": "^1.7.3",
    "eslint-config-gulp": "^2.0.0",
    "graceful-fs": "^3.0.0",
    "istanbul": "^0.3.0",
    "jscs": "^2.3.5",
    "jscs-preset-gulp": "^1.0.0",
    "marked-man": "^0.1.3",
    "mkdirp": "^0.5.0",
    "mocha": "^2.0.1",
    "mocha-lcov-reporter": "^0.0.1",
    "q": "^1.0.0",
    "rimraf": "^2.2.5",
    "should": "^5.0.1"   },   "engines": {
    "node": ">= 0.9"   },   "files": [
    "index.js",
    "lib",
    "bin",
    "completion",
    "gulp.1"   ],   "homepage": "http://gulpjs.com",   "license": "MIT",   "man": [
    "gulp.1"   ],   "name": "gulp",   "repository": {
    "type": "git",
    "url": "git+https://github.com/gulpjs/gulp.git"   },   "scripts": {
    "coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
    "lint": "eslint . && jscs *.js bin/ lib/ test/",
    "prepublish": "marked-man --name gulp docs/CLI.md > gulp.1",
    "pretest": "npm run lint",
    "test": "mocha --reporter spec"   },   "tags": [
    "build",
    "stream",
    "system",
    "make",
    "tool",
    "asset",
    "pipeline"   ],   "version": "3.9.1" }

my gulpfile.js

    var gulp = require('gulp');
var jshint = require('gulp-jshint');
var less = require('gulp-less');
var minifyCSS = require('gulp-minify-css');
var path = require('path');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var autoprefixer = require('gulp-autoprefixer');

gulp.task('less', function () {
    gulp.src('./assets/less/main.less')
    .pipe(less())
    .pipe(autoprefixer({
        browsers: ['last 2 versions'],
        cascade: false,
        remove: false,
    }))
    .pipe(minifyCSS())
    .pipe(gulp.dest('./assets/css'))
    .pipe(browserSync.reload({ stream: true }));
});


gulp.task('css', function () {
    gulp.src(['./assets/less/kendo/kendo.common.min.css',
    ])
        .pipe(concat('base.min.css'))

        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false,
            remove: false,
        }))

    .pipe(minifyCSS())
    .pipe(gulp.dest('./assets/css'))
    .pipe(browserSync.reload({ stream: true }));
    });

    gulp.task('integrate-less', function () {
        gulp.src('./assets/less/integrate.less')
            .pipe(less())
            .on('error', function (err) {
                this.emit('end');
            })
            .pipe(autoprefixer({
                browsers: ['last 2 versions'],
                cascade: false,
                remove: false
            }))
            .pipe(minifyCSS())

        .pipe(gulp.dest('./assets/css'))
        .pipe(browserSync.reload({ stream: true }));
});

//连接&缩小JS

gulp.task('scripts', function () {
    return gulp.src([

    'assets/js/editor/resources/colors.js',
    'assets/js/editor/resources/gradients.js',
    'assets/js/vendor/jquery.js',
    'assets/js/vendor/jquery_noty_packaged_min.js',
    'assets/js/vendor/kendo.all.min.js',
    'assets/js/vendor/jquery-ui.js',
    'assets/js/vendor/file-saver.js',
    'assets/js/vendor/bootstrap.min.js',
    'assets/js/vendor/Carousel.js',
    'assets/js/vendor/pagination.js',
    'assets/js/vendor/spectrum.js',
    'assets/js/vendor/hammer.js',
    'assets/js/vendor/scrollbar.js',
    'assets/js/vendor/angular.min.js',
    'assets/js/vendor/angular-animate.js',
    'assets/js/vendor/angular-aria.js',
    'assets/js/vendor/angular-material.js',
    'assets/js/vendor/angular-sortable.js',
    'assets/js/vendor/hotkeys.js',
    'assets/js/vendor/fabric.js',
    'assets/js/vendor/turn.min.js',
    'assets/js/editor/App.js',
    'assets/js/editor/Settings.js',
    'assets/js/editor/GetDirectory.js',
    'assets/js/editor/GetCookieValue.js',
    'assets/js/editor/AlbumPaging.js',
    'assets/js/editor/CheckProjectType.js',
    'assets/js/editor/GetCookie.js',
    'assets/js/editor/CheckSubmitOrder.js',
    'assets/js/editor/url.js',
    'assets/js/editor/LocalStorage.js',
    'assets/js/editor/resources/localization.js',
    'assets/js/editor/projects/projects.js',
    'assets/js/editor/projects/projectsPanelController.js',
    'assets/js/editor/shapes/sampleLayouts.js',
    'assets/js/editor/shapes/sampleLayoutsController.js',
    'assets/js/editor/shapes/rawLayouts.js',
    'assets/js/editor/shapes/Stickers.js',
    'assets/js/editor/shapes/rawLayoutsController.js',
    'assets/js/editor/Canvas.js',
    'node_modules/satellizer/dist/satellizer.js',
    'assets/js/editor/Canvas.js',
    'assets/js/editor/crop/cropper.js',
    'assets/js/editor/crop/cropzone.js',
    'assets/js/editor/crop/cropController.js',
    'assets/js/editor/basics/RotateController.js',
    'assets/js/editor/basics/CanvasBackgroundController.js',
    'assets/js/editor/basics/ResizeController.js',
    'assets/js/editor/basics/RoundedCornersController.js',
    'assets/js/editor/zoomController.js',
    'assets/js/editor/TopPanelController.js',
    'assets/js/editor/AlbumPagingController.js',
    'assets/js/editor/FabricExtensions.js',
    'assets/js/editor/Base64.js',
    'assets/js/editor/directives/Tabs.js',
    'assets/js/editor/directives/PrettyScrollbar.js',
    'assets/js/editor/directives/ColorPicker.js',
    'assets/js/editor/directives/FileUploader.js',
    'assets/js/editor/directives/TogglePanelVisibility.js',
    'assets/js/editor/directives/ToggleSidebar.js',
    'assets/js/editor/directives/FileManager.js',
    'assets/js/editor/text/Text.js',
    'assets/js/editor/text/TextController.js',
    'assets/js/editor/text/TextAlignButtons.js',
    'assets/js/editor/text/TextDecorationButtons.js',
    'assets/js/editor/text/Fonts.js',
    'assets/js/editor/drawing/Drawing.js',
    'assets/js/editor/drawing/DrawingController.js',
    'assets/js/editor/drawing/RenderBrushesDirective.js',
    'assets/js/editor/History.js',
    'assets/js/editor/Saver.js',
    'assets/js/editor/filters/FiltersController.js',
    'assets/js/editor/filters/Filters.js',
    'assets/js/editor/shapes/SimpleShapesController.js',
    'assets/js/editor/shapes/StickersController.js',
    'assets/js/editor/shapes/StickersCategories.js',
    'assets/js/editor/shapes/SimpleShapes.js',
    'assets/js/editor/shapes/Polygon.js',
    'assets/js/editor/objects/ObjectsPanelController.js',

])
    .pipe(concat('scripts.min.js'))
    // .pipe(uglify({
    //     compress: false,
    //     mangle: false,
    //     output: {
    //         beautify: false
    //     }
    // }))
    .pipe(gulp.dest('assets/js'))
        .pipe(browserSync.reload({ stream: true }));
});

// Watch Files For Changes
gulp.task('watch', function () {
    browserSync({
        //proxy: "localhost/pixie/",
        server: {
            baseDir: "./"
        }
    });

    gulp.watch('assets/js/**/*.js', ['scripts']);
    gulp.watch('assets/less/**/*.less', ['less']);
    gulp.watch('assets/less/**/integrate.less', ['integrate-less']);
});

// Default Task
gulp.task('default', ['less', 'css', 'scripts', 'watch']);

0 个答案:

没有答案