运行此命令后:
sudo npm install -g cordova
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
npm ERR! notarget No compatible version found: JSONStream@'>=1.0.3-0 <2.0.0-0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.0.0","0.1.0","0.1.1","0.1.2","0.1.3","0.2.0","0.2.1","0.2.2","0.2.3","0.3.0","0.3.1","0.3.2","0.3.3","0.4.0","0.4.1","0.4.2","0.4.3","0.4.4","0.5.0","0.6.0","0.6.1","0.6.2","0.6.3","0.6.4","0.7.0","0.7.1","0.8.0","0.7.2","0.7.3","0.7.4","0.8.1","0.8.2","0.8.3","0.8.4","0.9.0","0.10.0"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
Run Code Online (Sandbox Code Playgroud)
欢迎帮助.谢谢
我在我的项目中使用 browserify 并尝试需要一个需要jQuery作为全局变量的模块。我使用了browserify-shim一次将其设置为其中之一的
"jquery": "global:$"
"jquery": "global:jQuery"
"jquery": "$"
"jquery": "jQuery"
但似乎仍然没有任何作用。使用全局 jQuery 的库也在垫片中并设置为"depends": ["jquery"]
Browserify 正确地连接了 Javascript 包,但在运行 karma 测试时出现此错误Uncaught ReferenceError: jQuery is not defined 。我在 karma.conf.js 中指定了相同的 browserify-shim 配置。如何将 jQuery 设置为全局,以便它可以访问它而不抛出此错误。
我正在尝试使用 browserify 将我的服务器端代码捆绑到一个 JS 文件中。因此我在跑步
browserify --node -t coffeeify source/server.js.coffee -o deployment/server.js
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误
Error: Cannot find module '../build/Release/bufferutil' from '/My/Project/Path/node_modules/socket.io/node_modules/engine.io/node_modules/ws/lib'
Run Code Online (Sandbox Code Playgroud)
唯一的违规行似乎是require "socket.io". 当我删除它时,捆绑工作正常。如果我删除--node标志,它也可以正常工作。
当我检查目录时,“缺少”模块似乎在那里
ls node_modules/socket.io/node_modules/engine.io/node_modules/ws/build/Release/
Run Code Online (Sandbox Code Playgroud)
我懂了
.deps/ bufferutil.node* linker.lock obj.target/ validation.node*
Run Code Online (Sandbox Code Playgroud)
一些谷歌搜索让我找到了这个https://github.com/websockets/ws/issues/25。但这似乎是指旧版本的ws. ws模块中的版本已经超出了这个范围,我也已经尝试按照建议从源代码重建节点,但无济于事。
知道什么可能仍然导致此错误吗?
我正在开发一个Typescript项目,该项目被转换为ES5 JS,然后通过browserify运行以创建单个.js包和源图.捆绑的源映射指向已转换的JS而不是源TS,即使我正在生成源映射,这些源映射在转换为JS时正确指向源TS.
就好像browserify忽略了指向TS代码的现有源图并创建了自己的新映射到已编译的JS代码.
以下是我的gulp任务供参考 - 代码被编译到临时文件夹,然后从那里进行浏览.这使用browserify-incremental来支持增量编译.
谢谢!
注意:通过其他SO问题,我已经尝试过使用tsify,根据我的理解,它不适用于我的项目,因为我们使用import syntax&commonjs,它报告编译问题,其中tsc和gulp-typescript没有(相同的错误,无论是否通过使用gulp或通过CLI).我也试过minifyify,但它没有解决问题.
var gulp = require('gulp'),
ts = require('gulp-typescript'),
browserify = require('browserify'),
browserifyInc = require('browserify-incremental'),
source = require('vinyl-source-stream'),
del = require('del'),
sourcemaps = require('gulp-sourcemaps'),
buffer = require('vinyl-buffer'),
xtend = require('xtend');
var tsProject = ts.createProject('tsconfig.json');
//COMPILE TS
gulp.task('compileTs', function () {
var sourceTsFiles = [config.src.tsFiles, config.src.tsTypes];
var tsResult = gulp.src(sourceTsFiles)
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return tsResult.js
.pipe(sourcemaps.write('.', {
//includeContent: false,
//sourceRoot: "../../src/js/"
}))
.pipe(gulp.dest(config.tempDir));
});
//BUNDLE BUILT TS->JS
gulp.task('bundleJs', …Run Code Online (Sandbox Code Playgroud)这似乎是一个非常简单的问题,但花了最后3个小时来研究它,发现如果不使用watchify,每次保存新文件都会很慢.
这是我的目录树:
gulpfile.js
package.json
www/
default.htm
<script src="toBundleJsHere/file123.js"></script>
toBundletheseJs/
componentX/
file1.js
componentY/
file2.js
componentZ/
file3.js
toPutBundledJsHere/
file123.js
Run Code Online (Sandbox Code Playgroud)
要求.在文件夹中每次创建或保存文件时,toBundleTheseJs/我希望将此文件重新分组toBundleJsHere/
我需要在package.json文件中包含哪些内容?
什么是我需要写入我的gulp文件的最小值?
这应该尽可能快,所以认为我应该使用browserify并观察.我想了解最小步骤,所以使用像jspm这样的包管理器这一点太过分了.
谢谢
javascript browserify bundling-and-minification gulp watchify
我需要浏览一个文件,然后将包与另一个文件连接起来。我尝试了下面的 gulp 代码,但它无法正常工作。
当我在 mymodule.js 中进行更改并运行 gulp 时,这些更改会出现在捆绑文件中,但不会出现在串联文件中,除非我第二次运行 gulp。
就像连接步骤不等待捆绑步骤完成并获取之前浏览器化的捆绑一样。由于我是 gulp 的初学者,我确信我的 gulp 逻辑有问题......
我的吞咽文件是:
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var concat = require('gulp-concat');
gulp.task('default', function() {
var b = browserify('src/mymodule.js')
.bundle()
.pipe(source('mymodule-bundle.js'))
.pipe(gulp.dest('src'));
gulp.src([
'bower_components/porthole/src/porthole.min.js',
'src/mymodule-bundle.js'
])
.pipe(concat('app.js'))
.pipe(gulp.dest('dist'));
});
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在寻求有关获取外部 JSON 数据的最佳方式的建议。
我正在使用 browserify 并包含 JSON 数据,看起来像const data = require('mydata.json').
但是,我不想在 JSON 数据更新时编译 browserify JavaScript 文件。我在想 browserify 是否能够调用位于外部的 JSON,因此,我可以只更新 JSON 文件。
我的另一个选择是使用getJSON()外部调用 JSON 文件,我认为这种方法不是一种有效的方法。
如果有人有更好的选择?谢谢
我使用babel-plugin-transform-html-import-to-string将 html 模板文件导入到我的 javascript 组件中。
当我使用 watchify 时,如果 html 已更改,它不会更新。仅 Javascript 文件更改。npm 脚本是这样的:
watchify -p browserify-hmr -t [babelify ext .js .html] src/index.js -o public/bundle.js
由于这不起作用,我使用 watch 代替,如下所示,但我的构建至少比以前慢 5 秒,当它们是即时的。
watch 'npm run browserify' src/ -d --interval=1
browserify 脚本在哪里
browserify -t [babelify ext .js] src/index.js -o public/bundle.js
任何人都知道如何在不牺牲快速重建的情况下对 html 文件更改运行 browserify?
在 js 中导入 CSS 文件是特定于 webpack 的。如果我使用,gulp+browserify我将需要browserify-css. 我对编写直接依赖于 browserify-css 或 webpack 的源代码感到不舒服(特别是我不是在编写 React/Vue 应用程序,只是在编写 vanilla js)。
我发现了一些与此相关的问答,例如使用 Webpack 导入 CSS 和 JS 文件,我可以在 webpack 中构建 sass/less/css 而无需在我的 JS 中使用它们吗?
他们建议多入口点配置(如果我理解正确的话),即创建一个虚拟的 js 文件,import css并在 webpack.config.js 中为该 js 添加另一个条目,这样真正的条目 js 就不需要了import css
我试过了,但我仍然不喜欢这个解决方案。还有其他解决方案吗?如果有人可以确认没有,我也会很满意。B/C 其他人针对extract-text-webpack-plugin提出了同样的问题,回复说
webpack 本身只理解 'js-ish' 文件,不推荐使用 'css-ish' 文件作为入口点(恕我直言它甚至应该失败),所以每个 css 条目你都会得到一个虚拟包来“处理” . 要求/导入入口点内的 css
我有以下gulp任务来编译我的客户端代码:
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var reactify = require('reactify');
gulp.task('compile', function() {
return browserify('./public/js/app.js', {transform: reactify, debug: true})
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./public/dist'));
});
Run Code Online (Sandbox Code Playgroud)
问题是只有根./public/js/app.js文件显示在chrome的源选项卡中.app.js缺少所需的所有文件.
反编译源地图数据后,似乎只./public/js/app.js列出了相对网址,所有其他文件在我的机器上都有绝对网址.
{
"version": 3,
"sources": [
"/Users/andreaskoberle/projects/private/webshell/node_modules/browserify/node_modules/browser-pack/_prelude.js",
"./public/js/app.js",
"/Users/andreaskoberle/projects/private/webshell/public/js/cockpits/index.js",
"/Users/andreaskoberle/projects/private/webshell/public/js/cockpits/links.js",
"/Users/andreaskoberle/projects/private/webshell/public/js/common/Box.js",
"/Users/andreaskoberle/projects/private/webshell/public/js/common/Grid.js",
"/Users/andreaskoberle/projects/private/webshell/public/js/sidebar.js",
"/Users/andreaskoberle/projects/private/webshell/public/js/webShell/ScriptSelector.js",
"/Users/andreaskoberle/projects/private/webshell/public/js/webShell/ShellOutput.js",
"/Users/andreaskoberle/projects/private/webshell/public/js/webShell/index.js"
],
Run Code Online (Sandbox Code Playgroud) browserify ×10
gulp ×4
javascript ×4
watchify ×2
cordova ×1
css ×1
html ×1
jquery ×1
json ×1
jsonstream ×1
node.js ×1
npm ×1
socket.io ×1
source-maps ×1
typescript ×1
webpack ×1