- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用的是 Node v6.2.0。我有一个简单的 gulpfile,它编译 ts 文件并复制一些库。
但是当我尝试复制库时,我不断收到上述错误。
gulpfile.js:
const gulp = require("gulp");
const del = require("del");
const tsc = require("gulp-typescript");
const sourcemaps = require('gulp-sourcemaps');
const tsProject = tsc.createProject("tsconfig.json");
const tslint = require('gulp-tslint');
const config = require('./gulp.config.js');
const $ = require('gulp-load-plugins')({
lazy: true
});
// clean the contents of the distribution directory
gulp.task('clean', function() {
return del(config.dest, { force: true });
});
gulp.task('resources', function() {
_log('copy - ' + config.assets, $.util.colors.yellow);
return gulp.src(config.assets, { base: root })
.pipe(gulp.dest(config.dest));
});
/**
* Copy all required libraries into build directory.
*/
gulp.task("libs", () => {
_log('copying libs to:' + config.dest + 'lib' ,$.util.colors.yellow);
return gulp.src([
'es6-shim/es6-shim.min.js',
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'reflect-metadata/Reflect.js',
'rxjs/**',
'zone.js/dist/**',
'@angular/**'
], { cwd: 'node_modules/**' })
.pipe(gulp.dest(config.dest + 'lib'));
});
/**
* Compile TypeScript sources and create sourcemaps in build directory.
*/
gulp.task("compile", () => {
var tsResult = gulp.src(config.root + "**/*.ts")
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));
return tsResult.js
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(config.dest));
});
gulp.task("default", ['compile', 'resources', 'libs'], () => {
_log('Building the project ...', $.util.colors.yellow);
});
function _log(msg, color) {
color = color || $.util.colors.blue;
$.util.log(color(msg));
}
function _logError(error) {
_log('**** START OF ERROR ***', $.util.colors.red);
_log(error, $.util.colors.red);
_log('**** END OF ERROR ***', $.util.colors.red);
return error;
}
gulp.config.js
module.exports = (function() {
var root = './';
var config = {
root: root,
dest: '../dist/dashboard/',
assets: [
root + 'assets/**/*.*',
]
};
return config;
})();
错误堆栈:
[14:03:08] Using gulpfile C:\workspace\main\webserver\public\angular-client\dashboard\gulpfile.js [14:03:08] Starting 'compile'... [14:03:08] Starting 'resources'... [14:03:08] copy - ./assets/**/. [14:03:08] Starting 'libs'... [14:03:08] copying libs to:../dist/dashboard/lib (node:11076) DeprecationWarning: 'root' is deprecated, use 'global' path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path)); ^
TypeError: Path must be a string. Received { DTRACE_NET_SERVER_CONNECTION: [Function], DTRACE_NET_STREAM_END: [Function], DTRACE_HTTP_SERVER_REQUEST: [Function],
DTRACE_HTTP_SERVER_RESPONSE: [Function], DTRACE_HTTP_CLIENT_REQUEST: [Function], DTRACE_HTTP_CLIENT_RESPONSE: [Function],
COUNTER_NET_SERVER_CONNECTION: [Function],
COUNTER_NET_SERVER_CONNECTION_CLOSE: [Function],
COUNTER_HTTP_SERVER_REQUEST: [Function],
COUNTER_HTTP_SERVER_RESPONSE: [Function],
COUNTER_HTTP_CLIENT_REQUEST: [Function],
COUNTER_HTTP_CLIENT_RESPONSE: [Function], global: [Circular],
process: process { title: 'gulp', version: 'v6.2.0', ....
最佳答案
你的问题是这一行:
return gulp.src(config.assets, { base: root })
变量 root
未在您的 gulpfile 中定义。 Node.js 将此解释为对(已弃用)undocumented alias for global
的引用。 .
您可能想要:
return gulp.src(config.assets, { base: config.root })
关于node.js - gulp 抛出错误 : TypeError ('Path must be a string. Received ' + inspect(path)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37724227/
我是一名优秀的程序员,十分优秀!