标签: node-modules

我应该以什么顺序在我的共享模块中导入模块

我创建了一个如下所示的共享模块。我在某处读到进口订单很重要,但我现在找不到那个链接。在某些地方它工作正常,但在其他地方我收到错误。我想知道这些模块需要的顺序以避免任何错误。

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import 'hammerjs';

import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { MaterialModule } from '@angular/material';
import { FlexLayoutModule } from '@angular/flex-layout';
import { CoreModule } from './core/core.module';

// NOTE: The import order matters.
const modules = [
  CommonModule,
  CoreModule,
  ReactiveFormsModule,
  FormsModule,
  HttpClientModule,
  MaterialModule,
  FlexLayoutModule,
];

@NgModule({
  imports: modules,
  exports: modules
})
export class DependenciesModule { }
Run Code Online (Sandbox Code Playgroud)

node-modules angular

5
推荐指数
1
解决办法
3068
查看次数

如何在 npm build 中包含依赖项

如何在“npm run build”中包含运行时依赖项?我应该这样做吗?

如果没有,在另一台机器上运行构建的做法是什么?

node.js node-modules

5
推荐指数
0
解决办法
519
查看次数

错误找不到模块'@angular/material

错误

找不到模块'@angular/material

app.module.ts

import { MaterialModule } from '@angular/material';
Run Code Online (Sandbox Code Playgroud)

链接:https : //material.angular.io/guide/getting-started

 npm install --save @angular/material @angular/cdk
Run Code Online (Sandbox Code Playgroud)

我尝试过的解决方案

更新

它不起作用。

ng --version

@angular/cli: 1.2.1
node: 8.3.0
os: win32 x64
@angular/animation: 4.0.0-beta.8
@angular/animations: error
@angular/cdk: error
@angular/common: 4.3.2
@angular/compiler: 4.3.2
@angular/core: 4.3.2
@angular/forms: 4.3.2
@angular/http: 4.3.2
@angular/material: error
@angular/platform-browser: 4.3.2
@angular/platform-browser-dynamic: 4.3.2
@angular/router: 4.3.2
@angular/cli: 1.2.1
@angular/compiler-cli: 4.4.3
@angular/language-service: 4.3.2
Run Code Online (Sandbox Code Playgroud)
  • 任何人都可以在运行 npm 命令材料模块停止工作后建议我。

我已经做了工作演示https://github.com/afeef1915/Angular2-Symfony3-Demo

所有代码都运行良好。

  • 任何建议都是最受欢迎的。

安装材料时出错

    D:\Angular2-Symfony3-Demo-master>npm install --save @angular/material @angular/cdk
    npm WARN @angular/animation@4.0.0-beta.8 requires a peer of …
Run Code Online (Sandbox Code Playgroud)

npm node-modules angular

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

如何使 `npm install` 命令的详细输出日志静音?

这可能是一个愚蠢的问题,但我真的想知道有没有办法npm install通过删除整个包安装详细信息的详细信息,在运行命令时只查看错误/成功日志。

是否有任何有用的可选参数可以与npm install命令一起传递,它只会给出最少的日志,而没有对每个依赖项安装的详细描述?

command-line-arguments node.js npm node-modules npm-install

5
推荐指数
3
解决办法
7456
查看次数

如何获取除开发依赖项之外安装的 npm 模块的数量

是否有一个 NPM CLI 命令可以用来获取我的包中安装的 NPM 模块的数量,不包括那些只是开发依赖项的模块?npm ls显示所有包,但没有说明有多少或哪些是开发依赖项,哪些不是。谢谢!

javascript node.js npm node-modules npm-install

5
推荐指数
2
解决办法
3229
查看次数

类型文档。如何导入一个 node_modules/@types 并像 IncludeDeclarations 一样固定对它的引用

我正在尝试生成我的应用程序的文档(使用 TypeDoc)。我有相当困难的场景要做。所以在我的代码中是一些函数,它返回类型为 from 的对象node_modules/@types。我需要将此类型包含在我的文档中,因为我需要显示对此的引用@type并且我也需要显示它@type。所以我正在尝试这些方法:

  1. 在“src”语句中添加了此类型的路径,例如:'**/node_modules/@types/someType/index.d.ts'。我的 TypeDoc 配置:

    typedoc: {
        build: {
            options: {
                module: 'commonjs',
                out: '../MyDocumentation/',
                name: 'MyApp',
                target: 'es5',
                exclude: [
                    '**/folderA/*.d.ts',
                    '**/folderB/*.d.ts'
                ],
                excludePrivate: true,
                externalPattern: "**/*/{fileX,fileY,fileZ}.ts",
                mode: 'file'
            },
            src: [
                'folderA/*.ts',
                'folderB/*.ts',
                '**/node_modules/@types/someType/*.d.ts'
            ]
        }
    }  
    
    Run Code Online (Sandbox Code Playgroud)
  2. 通过将 includeDeclarations 设置为 true。我的 TypeDoc 配置:

    typedoc: {
        build: {
            options: {
                module: 'commonjs',
                out: '../MyDocumentation/',
                name: 'MyApp',
                target: 'es5',
                exclude: [
                    '**/node_modules/**',
                    '**/folderA/*.d.ts',
                    '**/folderB/*.d.ts'
                ],
                includeDeclarations: true,
                excludePrivate: true,
                externalPattern: …
    Run Code Online (Sandbox Code Playgroud)

documentation node-modules gruntjs typescript typedoc

5
推荐指数
0
解决办法
660
查看次数

通过命令行或 ES6 导入运行 Node.js 脚本

如何编写可以从命令行或通过 ES6 导入语句运行的 Node 脚本?

我正在使用--experimental-modules标志和.mjs扩展来将脚本作为 ES6 模块运行。

例子

假设我有以下脚本sayHello.mjs:

export default function sayHello() {
  console.log(`Hello!`);
}
Run Code Online (Sandbox Code Playgroud)

我希望能够通过以下两种方式使用此脚本:

  1. 通过命令行:

    node --experimental-modules sayHello.mjs
    
    Run Code Online (Sandbox Code Playgroud)
  2. 通过另一个脚本中的 ES6 导入语句:

    node --experimental-modules sayHello.mjs
    
    Run Code Online (Sandbox Code Playgroud)

细节

我正在寻找类似于module.main用于 CommonJS 模块的解决方案(这不适用于 ES6 导入):

import sayHello from './sayHello.mjs';

sayHello();
Run Code Online (Sandbox Code Playgroud)

javascript node.js node-modules es6-modules

5
推荐指数
1
解决办法
3220
查看次数

在文件之间共享 mqtt 客户端对象

我以这种方式连接到 MQTT:

//mqtt.js

const mqtt = require('mqtt');

var options = {
    //needed options
};

var client = mqtt.connect('mqtt://someURL', options);

client.on('connect', () => {
    console.log('Connected to MQTT server');
});
Run Code Online (Sandbox Code Playgroud)

我想以这种方式导出客户端对象:

//mqtt.js

module.exports = client;
Run Code Online (Sandbox Code Playgroud)

这样我就可以将它导入其他文件并以这种方式使用它:

//anotherFile.js    

const client = require('./mqtt');
client.publish(...)
Run Code Online (Sandbox Code Playgroud)

但是,我们都知道这是行不通的!我怎样才能做到这一点?

更新

我尝试了promise并得到了一个非常奇怪的行为。当我像下面的代码一样在同一个文件 (mqtt.js) 中使用 promise 时,一切正常:

//mqtt.js
const mqtt = require('mqtt');

var mqttPromise = new Promise(function (resolve, reject) {

    var options = {
     //needed options
    };
    var client = mqtt.connect('mqtt://someURL', options);

    client.on('connect', () => { …
Run Code Online (Sandbox Code Playgroud)

export node.js mqtt node-modules

5
推荐指数
1
解决办法
789
查看次数

require() 函数的 Node.js 源代码

根据文档(https://nodejs.org/api/globals.html),require()函数是全局对象/函数之一。但是我很难在 Github 上找到它的源代码。它们是用 JS 还是 C++ 编写的?我在https://github.com/nodejs/node项目中寻找它们。

javascript require node.js node-modules

5
推荐指数
1
解决办法
1397
查看次数

对 node_module 的更改未反映 reactjs

我正在使用react-html-table-to-excel,我想做的是更改导出按钮的样式。因此,我将文件定位在:node_module/react-html-table-to-excel/src/ReactHTMLTableToExcel.jsx并按照我想要的方式更改了它。

但是,当我保存文件并刷新浏览器时,更改并未反映在浏览器中。为了确保,我什至注释掉了整个文件并重新启动了服务器,但仍然没有对导出按钮进行任何更改。

任何帮助是极大的赞赏!

node-modules reactjs

5
推荐指数
1
解决办法
1274
查看次数