我试图将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)
任何想法,如何解决这个问题?
当将编译器选项的以太module或target属性设置为 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 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 库中?它是一个同时使用前端和后端的库,因此使用导入/导出很重要。
谢谢
我正在尝试使用我的 Mac M1 将功能部署到 firebase,为此需要npm install在node_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) 我正在尝试打包一些我一直在研究的模块.我有五个模块,分成五个文件.其中四个是我希望用户能够安装的实际外向模块.另一个是支持模块,它们都需要正常运行.它们都存储在同一目录中.我希望能够将每个指定为同一目录中的单独模块.但据我所知,人们只能定义一个模块package.json.
有没有办法指定多个模块?如果没有,那意味着这一定是一种不好的做法.我应该如何构建模块的导出以将其移入一个主模块?
我正在使用一个使用节点回调约定的节点模块.我想使用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错误.我该如何解决?
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 undefined的node_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) 我通过npm包管理器使用了很多Node.js模块.由于这些模块不是由值得信赖的组织开发的,它们是否值得信赖?
我不知道npm团队是否正在对开发人员提交的每个模块进行任何安全检查.
我想知道在我们使用docker开发应用程序时以及当我们只在本地docker容器内部使用node_modules时,是否可以配置VS Code IntelliSense?
提前致谢!
我尝试运行 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) node-modules ×10
node.js ×6
npm ×4
javascript ×3
typescript ×2
angular ×1
bluebird ×1
callback ×1
ecmascript-6 ×1
firebase ×1
git ×1
icu ×1
intellisense ×1
promise ×1
security ×1
server ×1
ts-loader ×1
xml-parsing ×1