标签: node-modules

具有合并流的gulp-order节点模块

我正在使用gulp-order模块以及event-streams模块和gulp-concat将javascript文件连接到单个dest文件中.gulp-order插件在我想要以不同顺序连接流中的文件的其他项目中对我很有用.由于某些原因,在这个项目中,它无法正常工作,并且public/angular/config目录中的文件分散在我指定的文件中,以便在public/js目录中最后连接.我认为这可能与指定多个来源有关.angular和js目录.我尝试将流与事件流模块合并而没有运气,而当我第一次开始时,我通过将数组传递给gulp.src函数来指定多个源

gulp.src(['./public/angular/**/*.js', './public/js/*.js'])
Run Code Online (Sandbox Code Playgroud)

下面是我现在使用的代码.管道和连接工作正常,但顺序不符合规范:

var gulp         = require('gulp');
var concat       = require('gulp-concat');
var notify       = require('gulp-notify');
var handleErrors = require('../util/handleErrors');
var jshint       = require('gulp-jshint');
var ngmin        = require('gulp-ngmin');
var order        = require('gulp-order');
var es           = require('event-stream');

function getStream(streamPath) {
  return gulp.src(streamPath);
};

gulp.task('scripts', function() {
    return es.merge(getStream('./public/angular/**/*.js'),getStream('./public/js/*.js'))
        .pipe(order([
          './public/angular/config/*.js',
          './public/angular/services/**/*.js',
          './public/angular/modules/**/*.js',
          './public/angular/primitives/**/*.js',
          './public/js/**/*.js'
        ]))
        .pipe(concat('app.js'))
        .pipe(gulp.dest('./public/build/js'))
        .on('error', handleErrors);
});
Run Code Online (Sandbox Code Playgroud)

concat node.js angularjs node-modules gulp

6
推荐指数
1
解决办法
3974
查看次数

Visual Studio - 在文件中查找>不是任何node_modules文件夹

所以在Visual Studios中你可以"在文件中查找"一个字符串 - 我发现这对于找到一个可以找到一些标记或JS的文件非常有用,我使用VS作为我的主代码编辑器进行Web开发.

问题是,我的大多数项目都使用node.js和基于节点的构建工具grunt/gulp等.所以我的项目中的某个地方有一个node_modules文件夹,因为有数千个文件,所以FIND会一直存在!

如何在文件和文件夹中搜索字符串但不在node_modules目录中搜索.

在SublimeText2中,您可以从项目中删除文件夹而不删除它,这将停止搜索在那里...

RegExp将用于字符串而不是filePath :(

findinfiles visual-studio node-modules visual-studio-2012 visual-studio-2013

6
推荐指数
1
解决办法
2894
查看次数

Cordova 4.3.0 - 构建命令返回错误找不到模块'Q'

将cordova更新到版本4.3.0后,命令:

cordova build
Run Code Online (Sandbox Code Playgroud)

返回以下错误:

    module.js:340
    throw err;
          ^
Error: Cannot find module 'Q'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/lib/check_reqs.js:25:13)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
ERROR building one of the platforms: Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
    at ChildProcess.whenDone …
Run Code Online (Sandbox Code Playgroud)

xcode npm node-modules cordova cordova-cli

6
推荐指数
1
解决办法
1万
查看次数

打字稿模块解析

是否有一个打字稿模块解析策略,允许我让本地导入不是以斜杠开头,而是从同一模块中的node_modules导入?

将"moduleResolution"设置为"node"时,编译器找不到我的本地模块,所有其他选项都没有看到我正在尝试导入的node_modules目录中的模块.

我的文件中有以下导入:

import {Injectable} from "angular2/core";
import {Logger} from "core/logging/Logger";
Run Code Online (Sandbox Code Playgroud)

"angular2/core"位于node_modules中,"core/logging/Logger"是我的本地模块.

我认为这应该是可能的,如果你看看角度的代码,他们似乎有两个,即.在http.ts模块中:https: //github.com/angular/angular/blob/master/modules/angular2/src/http/http.ts

import {Injectable} from 'angular2/core'; //this is local
import {Observable} from 'rxjs/Observable'; //this probably comes from node_modules
Run Code Online (Sandbox Code Playgroud)

更多背景信息:
我有一个由两个子项目组成的项目:
- library
- app
Library定义了一些应用程序随后使用的实用程序.我的构建过程首先构建'library'子项目,然后将它(与d.ts文件一起编译的js)复制到'app的node_modules中的'library'子文件夹,然后编译'app'.

在'library'中我有以下类:

//file project/library/jsonparser/JSONParser.ts
class JSONParser {...} 

//file project/library/services/ConfigurationService.ts
import {JSONParser} from "../jsonparser/JSONParser"
class ConfigurationService {
  constructor(parser: JSONParser){ ... }
}
Run Code Online (Sandbox Code Playgroud)

在'app'中:

import {JSONParser} from "library/jsonparser/JSONParser" //this comes from node_modules in 'app'
import {ConfigurationService} from "library/services/ConfigurationService" //from node_modules
class AppConfigurationService …
Run Code Online (Sandbox Code Playgroud)

node-modules typescript tsconfig

6
推荐指数
1
解决办法
3875
查看次数

什么被认为是在节点模块内共享"全局"变量的好方法?

如何在没有显式相对路径(../../../lib..)的情况下轻松引用模块中的其他目录?

我正在编写节点模块,我想在模块中重用一些全局内容.
最基本的 - 我想将模块的根路径设置为"全局",这样我就可以轻松地调用其他源,而无需使用大量相对路径../../和类似的东西.它可能会导致代码混乱,如果项目结构发生变化,很容易出错或错过它.

所以我在该帖子和其他一些库中看到了很多选项来处理这些事情(例如提供根路径的模块 - app-module-path,rootpath,rfr等)但是它们都引用了基础项目/应用程序,而不是其他人使用的模块.

设置全局是一个坏主意,我理解环境变量也不是一个好主意.

那件事有好的做法吗?也许有一些我没有找到或听说过的东西.

以下是我要避免的内容和我正在寻找的内容的示例:

// avoid things like that:

// ./lib/something/forthat/doit.js
var config = require('../../../config/project/type1/config.js');

// ./config/project/type1/config.js
module.exports = {
  msg: 'hi'
};


// find somethings like that:
// when the root path/require can be found in every location of the module
// and is relative to my app and not the app using my module.

// ./lib/something/forthat/doit.js
var config = …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm node-modules

6
推荐指数
1
解决办法
215
查看次数

如何在node.js中的多个文件之间拆分类定义?

我的类定义Foo已经发展到我想将它分成多个文件的程度.例如,我想要像:

// file foo.js
'use strict';
function Foo() { };
Foo.prototype.constructor = Foo;
Foo.prototype.methodA = function() { console.log('methodA'); };
module.exports = Foo;

// file foo-aux.js
'use strict';
Foo.prototype.methodB = function() {
  console.log('methodB');
  this.methodA();
};

// file main.js
'use strict';
const Foo = require('./foo');
var foo = new Foo();
foo.methodB();
Run Code Online (Sandbox Code Playgroud)

什么是上述代码的正确组合module.export和require()使用?

require node.js node-modules

6
推荐指数
2
解决办法
2530
查看次数

打字稿:如何解析node.js的绝对模块路径?

我需要基于baseUrl此解析模块,因此输出代码可用于node.js

这是我的 src/server/index.ts

import express = require('express');
import {port, databaseUri} from 'server/config';

...
Run Code Online (Sandbox Code Playgroud)

这是我的 src/server/config/index.ts

export const databaseUri: string = process.env.DATABASE_URI || process.env.MONGODB_URI;
export const port: number = process.env.PORT || 1337;
Run Code Online (Sandbox Code Playgroud)

运行tsc我能够编译没有错误的所有文件,但输出:dist/server/index.js是

"use strict";
var express = require("express");
var config_1 = require("server/config");

...
Run Code Online (Sandbox Code Playgroud)

结果Cannot find module 'server/config'如果我正在尝试使用它node dist/sever/index.js.

为什么server/config路径没有以任何方式解决,因此可以使用已编译的代码或如何解决它.或者我在做什么或者想错的方式?

我的tsc --version是2.1.4

这是我的tsconfig.json:

{
  "compileOnSave": true,
  "compilerOptions": {
      "baseUrl": "./src",
      "rootDir": "./src",
      "module": "commonjs", …
Run Code Online (Sandbox Code Playgroud)

javascript node.js node-modules typescript

6
推荐指数
1
解决办法
2176
查看次数

外部JavaScript库在'{module}/dist /'上返回404

在Angular2中配置外部项目总是遇到一些麻烦.

我想在我的项目中包含ng2-sharebuttons.(似乎没有全局.d.ts文件?)

虽然README.md只是说npm install ng2-sharebuttons --save,我知道还有更多的东西(systemjs.config&typings)

首先,我尝试配置systemjs.config:

map{
     ......
     'ng2-sharebuttons' : 'node_modules/ng2-sharebuttons'
}
Run Code Online (Sandbox Code Playgroud)

这至少固定在404上localhost/ng2-sharebuttons,但创造了一个新404的localhost/node_modules/ng2-sharebuttons.

所以,我添加了一个主文件,systemjs.config改为

map{
     ......
     'ng2-sharebuttons' : 'node_modules/ng2-sharebuttons/dist/index.js'
}
Run Code Online (Sandbox Code Playgroud)

但现在这导致了404每个孩子ng2-sharebuttons/dist

我尝试过typings install ng2-sharebuttons --save --global,typings install @types/ng2-sharebuttons --save --global无论有没有--global旗帜.

所以在我最后的希望中,我添加了一个参考,看看是否可行.添加

/// <reference path="../../node_modules/ng2-sharebuttons/dist/index.d.ts" />

但这并没有改变任何事情.

我忘记了什么?为什么这么难?(或者我只是努力吗?)

结构和文件ng2-sharebuttons:

在此输入图像描述

最后,Chrome目前正在生成错误消息:

在此输入图像描述

整个 systemjs.config.js

/**
 * System …
Run Code Online (Sandbox Code Playgroud)

node-modules typescript systemjs angular

6
推荐指数
1
解决办法
547
查看次数

npm相当于yarn install和yarn webpack:build

Jhipster的http://www.jhipster.tech/installation/允许在其他问题上使用yarn或npm,使用JHipster 4生成的应用程序返回8080而不是9000的空白页。 建议运行yarn install和yarn webpack :build我是UI开发的新手,只允许使用npm,所以我想知道什么等同于yarn install 和yarn webpack:build

我生成了一个新项目

D:\ rajblog> jhipster --npm使用全局安装的JHipster版本运行默认命令执行jhipster:app选项:npm:true

(不适用于“ yo jhipster --npm”),它会自动称为“ npm install”,但是当我运行“ npm webpack:build”时,它没有运行,我得到了

D:\ rajblog> npm webpack:build

用法:npm

其中之一是:

和

D:\ rajblog> npm webpack-build

用法:npm

其中之一是:访问,adduser,bin,bug,c,缓存,完成,配置,ddp,重复数据删除,不赞成使用,dist-tag,docs,doctor,edit,explor,get,help,help-search,i,init ,安装,安装测试,链接,列表,ln,登录,注销,ls,过时,所有者,包,ping,前缀,配置文件,修剪,发布,rb,重建,回购,重新启动,root,运行,运行-script,s,se,搜索,设置,shrinkwrap,星,星,开始,停止,t,团队,测试,令牌,tst,un,卸载,取消发布,取消星标,向上,更新,v,版本,视图,whoami

npm -h npm -l快速帮助显示完整的使用情况信息npm help搜索有关npm help的帮助npm涉及的概述

在ini格式的文件中指定配置:C:\ Users \ XXUid.npmrc或在命令行上通过以下方式指定:npm-键值可以通过以下方式查看配置信息:npm help config

npm@5.5.1 D:\ nodejs \ node_modules \ npm

npm node-modules jhipster yarnpkg angular

6
推荐指数
1
解决办法
922
查看次数

React Native构建错误:文本不能为null或为空

我的Jenkins版本给了我以下错误:

13:18:22 FAILURE: Build failed with an exception.
13:18:22 
13:18:22 * Where:
13:18:22 Script '/Users/abcd/Jenkins/Jenkins-Workspaces/ABCD/ABCDL/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 190
13:18:22 
13:18:22 * What went wrong:
13:18:22 A problem occurred evaluating settings 'AppName'.
13:18:22 > Text must not be null or empty
13:18:22 
Run Code Online (Sandbox Code Playgroud)

似乎问题出在@react-native-community/cli-platform节点模块上,但请阅读以下已关闭的问题:https : //github.com/facebook/react-native/issues/25479

对我来说尚不清楚,对此提出的最终解决方案到底是什么。

有一个关于此本地问题的更简单修补程序的建议:https : //github.com/facebook/react-native/issues/25822

但我的错误不是抱怨那条线。

至于安装,@react-native-community/cli我相信我已经在package-lock.json文件中包含了它:

"react-native": {
      "version": "0.60.4",
      "resolved": "https://registry.npmjs.org/react-native/-/react-native-0.60.4.tgz",
      "integrity": "sha512-WE41lbGQjnzM9srIFtMDtMJkQAvk95iZwuFvAxl68s80bkYa7Ou9sGFHpeYIV6cY8yHtheCSo5q6YMxhdfkdOw==",
      "requires": {
        "@babel/runtime": "^7.0.0",
        "@react-native-community/cli": "^2.0.1",
        "@react-native-community/cli-platform-android": "^2.0.1",
        "@react-native-community/cli-platform-ios": "^2.0.1",
Run Code Online (Sandbox Code Playgroud)

其他人提到了有关的内容app/build.gradle,这是我的相关部分:

// Run …
Run Code Online (Sandbox Code Playgroud)

apk jenkins node-modules react-native

6
推荐指数
1
解决办法
1416
查看次数