标签: node-modules

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
查看次数

无法让“npm install -g”在任何包上工作(AppData/Roaming/npm 总是空的)

在工作时在 Windows 7 Enterprise 上运行 nodejs。

每当我安装需要 -g 访问权限的 node_module 时,根据经验,我知道它应该在 .bat 中创建一个 *.bat 文件%AppData$/Roaming/npm,但由于某种原因它不再这样做了。

例如,我将运行npm install gulp -g,控制台看起来安装正确,但文件不会在 AppData 文件夹中。如果我尝试运行 gulp 命令,我会收到 error sh.exe": gulp: command not found。

如果我npm install gulp -g以管理员身份在控制台中运行该命令,它会将文件安装到管理员(而不是普通用户)的 %AppData% 文件夹中。因此,如果我通过我的非管理员用户运行 gulp 命令,我仍然会收到 error sh.exe": gulp: command not found。

有任何想法吗?

windows-7 node.js npm node-modules gulp

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
查看次数

为什么 NPM 模块的依赖项总是可以安装到嵌套的 node_modules 中?

如您所知,NPM v3 尝试使依赖关系树尽可能平坦。以前我认为它以嵌套方式安装依赖项只是为了解决冲突,以防同一模块有多个版本。

但是,我注意到 module 有一些奇怪的地方protractor。它有一个依赖项 ,webdriver-manager它总是以嵌套的形式安装到node_modules/protractor/node_modules。您可以通过npm install protractor在空文件夹中运行来轻松重现这一点。

为什么会发生这种情况?

npm node-modules protractor

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

外部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
查看次数

在多个项目之间共享 node_modules 目录

我是一名学习 EC6 的 Java 开发人员。我使用 npm 下载 JavaScript 包,使用 webpack 创建最终的 bundle.js 文件。

我有一个不错的项目文件夹,其中包含带有 java 文件的 java 模块,我想将 EC6 JavaScript 文件添加到我的 web 模块中。我使用 maven 来管理 java jar 依赖库。

这是我的文件夹结构:

my-project
  |-common-module
  |-ejb-module
  |-web-module-1
  |   |-src
  |       |-main
  |           |-java
  |               |-com.a.b
  |                   |-Hello.java
  |           |-webapp
  |               |-index.jsp
  |               |-bundle.js
  |               |-package.json
  |               |-webpack.config.js
  |               |-WEB-INF
  |               |-node_modules <-- I WANT THIS FOLDER TO BE MOVED AWAY FROM HERE 
  |               |-app          <-- react + ec6 javascript files
  |                   |-action
  |                   |-components …
Run Code Online (Sandbox Code Playgroud)

javascript java npm node-modules npm-install

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

如何使用 Browserify 和 Gulp 启动多页应用程序

好的,我使用 Gulp 和 Browserify 构建的新 PHP/JS 应用程序接近终点线。最后一部分是如何“启动”,我的意思是如何进行“第一次调用”。

假设我有 3 个 JS 入口点

/js/articles.js
/js/categories.js
/js/comments.js
Run Code Online (Sandbox Code Playgroud)

他们每个人都使用一些 JS 模块。然后我有 3 个 HTML 文件,需要它们的 JS

/articles.html
/categories.html
/comments.html
Run Code Online (Sandbox Code Playgroud)

示例/js/articles.js

var $ =                 require("jquery");
var common =            require("../common.js");

var viewModel = {

    readData: function() {
        /* read record from API and render */
    },

    insert: function() {
        /* open a modal to insert new record */
    }
};
Run Code Online (Sandbox Code Playgroud)

我现在应该做的是执行这种“启动”:即调用我需要的一些 init 函数,然后加载服务器数据,然后将所有按钮和东西绑定到 viewModel 的方法

$(document).ready(function() {
    common.init();
    viewModel.readData();
    $('#btn-add').click(viewModel.insert);
});
Run Code Online (Sandbox Code Playgroud)

好的,但是我把这个放在哪里?

A) 在 HTML …

javascript node.js node-modules browserify gulp

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

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
查看次数