标签: node-modules

node:无法初始化ICU(检查NODE_ICU_DATA或--icu-data-dir参数)

我试图将CI环境中的节点版本从节点6升级到节点8.我也更新了full-icu版本.

$NODE_ICU_DATA被设置为/usr/lib/node_modules/full-icu

但仍然得到这个错误

node: could not initialize ICU (check NODE_ICU_DATA or --icu-data-dir parameters)
Run Code Online (Sandbox Code Playgroud)

任何想法,如何解决这个问题?

icu node.js node-modules

13
推荐指数
3
解决办法
5322
查看次数

打字稿:esnext 编译器选项会破坏来自外部库的 es6 导入

当将编译器选项的以太moduletarget属性设置为 esnext(id 喜欢使用import("example")语句)时,es6 导入语句将停止为npm installed 库工作(本地模块仍然工作:例如"./test.ts")。

所以这import * as asd from "testmodule";抛出cannot find module 'testmodule'. 然而,省略这两个属性使它工作。这是为什么,我应该使用什么标准来保留import("example")import * as asd from "testmodule";声明?


这是我的完整 tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./dist/",
    "module": "esnext",
    "target": "esnext",
    "allowJs": true,
    "sourceMap": true
  }
}

Run Code Online (Sandbox Code Playgroud)

node-modules typescript

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

NodeJS(服务器):ReferenceError:需要在类型:模块时未定义

在 Node 13.8 上,我尝试使用导入/导出。

例如: import {ChatClient, Message, MessageParser} from './chat-client/module.js';

但是当我这样做时,我得到

SyntaxError: Cannot use import statement outside a module

所以在我的 package.json 中我设置了"type" : "module"但是现在当我尝试使用const io = require('socket.io-client');

我得到 ReferenceError: require is not defined

有没有办法使用导入/导出和要求?

最初的错误,这是否意味着我必须将我的库包装在 NPM 库中?它是一个同时使用前端和后端的库,因此使用导入/导出很重要。

谢谢

node.js node-modules server

13
推荐指数
2
解决办法
7151
查看次数

“darwin-arm64v8”二进制文件不能在“darwin-x64”平台上使用

我正在尝试使用我的 Mac M1 将功能部署到 firebase,为此需要npm installnode_modules/. 我收到此错误:

Error: 'darwin-arm64v8' binaries cannot be used on the 'darwin-x64' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'darwin-x64' platform.
    at Object.hasVendoredLibvips (/Users/ali/Desktop/tajir/backend-mvp/appengine/back-end-flex/node_modules/sharp/lib/libvips.js:80:13)
    at Object.<anonymous> (/Users/ali/Desktop/tajir/backend-mvp/appengine/back-end-flex/node_modules/sharp/lib/constructor.js:7:22)
    at Module._compile (internal/modules/cjs/loader.js:1136:30)
    at Module._compile (pkg/prelude/bootstrap.js:1394:32)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
    at Module.load (internal/modules/cjs/loader.js:984:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1024:19)
    at Module.require (pkg/prelude/bootstrap.js:1338:31)
    at require (internal/modules/cjs/helpers.js:72:18)

Run Code Online (Sandbox Code Playgroud)

node.js node-modules firebase google-cloud-functions

13
推荐指数
3
解决办法
2万
查看次数

在同一个Package.json文件中记录多个模块

我正在尝试打包一些我一直在研究的模块.我有五个模块,分成五个文件.其中四个是我希望用户能够安装的实际外向模块.另一个是支持模块,它们都需要正常运行.它们都存储在同一目录中.我希望能够将每个指定为同一目录中的单独模块.但据我所知,人们只能定义一个模块package.json.

有没有办法指定多个模块?如果没有,那意味着这一定是一种不好的做法.我应该如何构建模块的导出以将其移入一个主模块?

node.js npm node-modules

12
推荐指数
1
解决办法
9115
查看次数

蓝鸟承诺`promisifyAll`不工作 - 无法读取属性`then`

我正在使用一个使用节点回调约定的节点模块.我想使用Bluebird承诺将此模块转换为API.我没有得到如何做到这一点.

下面是我的节点样式回调函数.我想将它转换成蓝鸟的可靠承诺.

var module = require('module'); // for example xml2js, or Mongoose
var parseString = xml2js.parseString; 
    parseString(xml, function (err, result) { // the regular API
      if (err) {
       console.log("Error in generation json from xml");
      } else {
       return result;
      }
    });
Run Code Online (Sandbox Code Playgroud)

我试过这种方式,PromisifyAll但它不起作用:

var module = Promise.promisifyAll(require('module')); // for example xml2js
xml2js.parseString(xml)
        .then(function (result) {
            console.log("result = ", result);
        })
        .catch(function (err) {
            console.err(err);
        });
Run Code Online (Sandbox Code Playgroud)

我收到了then is not a function错误.我该如何解决?

callback xml-parsing promise node-modules bluebird

12
推荐指数
1
解决办法
2345
查看次数

如何在Typescript 1.8中包含无类型的节点模块?

Typescript 1.8现在支持无类型的JS文件.要启用此功能,只需添加编译器标志--allowJs或将"allowJs":true添加到tsconfig.json中的compilerOptions

通过https://blogs.msdn.microsoft.com/typescript/2016/01/28/announcing-typescript-1-8-beta/

我正在尝试导入没有打字文件的react-tap-event-plugin.

import * as injectTapEventPlugin from 'injectTapEventPlugin'; 
Run Code Online (Sandbox Code Playgroud)

说找不到模块.所以我试过:

import * as injectTapEventPlugin from '../node_modules/react-tap-event-plugin/src/injectTapEventPlugin.js';
Run Code Online (Sandbox Code Playgroud)

这表示模块解析为非模块实体,无法使用此结构导入.然后我尝试了:

import injectTapEventPlugin = require('../node_modules/react-tap-event-plugin/src/injectTapEventPlugin.js');
Run Code Online (Sandbox Code Playgroud)

它与崩溃ERROR in ./scripts/index.tsx Module build failed: TypeError: Cannot read property 'kind' of undefinednode_modules/typescript/lib/typescript.js:39567

我的tsconfig:

{
  "compilerOptions": {
  "target": "ES5",
  "removeComments": true,
  "jsx": "react",
  "module": "commonjs",
  "sourceMap": true,
  "allowJs": true
  },
  "exclude": [
    "node_modules"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我正在使用带有ts-loader的webpack:

 {
   test: /\.tsx?$/,
   exclude: ['node_modules', 'tests'],
   loader: 'ts-loader'
 }
Run Code Online (Sandbox Code Playgroud)

javascript node-modules typescript ecmascript-6 ts-loader

12
推荐指数
1
解决办法
3681
查看次数

我们如何信任npm模块?

我通过npm包管理器使用了很多Node.js模块.由于这些模块不是由值得信赖的组织开发的,它们是否值得信赖?

我不知道npm团队是否正在对开发人员提交的每个模块进行任何安全检查.

javascript security node.js npm node-modules

12
推荐指数
1
解决办法
1688
查看次数

当docker容器中的node_modules时,VS Code IntelliSense

我想知道在我们使用docker开发应用程序时以及当我们只在本地docker容器内部使用node_modules时,是否可以配置VS Code IntelliSense?

提前致谢!

javascript intellisense npm node-modules visual-studio-code

12
推荐指数
1
解决办法
664
查看次数

npm install 返回 syscall spawn git 错误

我尝试运行 npm install 并在下面遇到这些问题

我尝试使用强制命令清除缓存,安装 git 和更新节点,但没有任何效果

这是错误

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found …
Run Code Online (Sandbox Code Playgroud)

git node.js npm node-modules angular

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