Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 是';El Capitan';s';无根破旧咕噜?_Node.js_Gruntjs_Grunt Contrib Watch_Grunt Contrib Uglify_Grunt Contrib Concat - Fatal编程技术网

Node.js 是';El Capitan';s';无根破旧咕噜?

Node.js 是';El Capitan';s';无根破旧咕噜?,node.js,gruntjs,grunt-contrib-watch,grunt-contrib-uglify,grunt-contrib-concat,Node.js,Gruntjs,Grunt Contrib Watch,Grunt Contrib Uglify,Grunt Contrib Concat,迁移到El Capitan后,用户似乎遇到了grunt安装问题,可能与El Capitan的无根更改有关。特别是,运行grunt--force命令会导致EPERM错误。工作流程如下: Running "concat:dist" (concat) task Warning: Unable to write "../js/pro/global.js" file (Error code: EPERM). Used --force, continuing. Running "uglify:build"

迁移到El Capitan后,用户似乎遇到了grunt安装问题,可能与El Capitan的无根更改有关。特别是,运行grunt--force命令会导致EPERM错误。工作流程如下:

Running "concat:dist" (concat) task
Warning: Unable to write "../js/pro/global.js" file (Error code: EPERM). Used --force, continuing.

Running "uglify:build" (uglify) task
Warning: Unable to write "../js/pro/global.min.js" file (Error code: EPERM). Used --force, continuing.

Running "compass:dev" (compass) task
Warning: Command failed: /bin/sh: compass: command not found. Used --force, continuing.
Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.

Running "svgstore:defaults" (svgstore) task
Warning: Unable to write "../img/svg-defs.svg" file (Error code: EPERM). Used --force, continuing.

Running "watch" task
Waiting...
假设已安装npm,使用package.json和grunfile.js导航到grunt目录并调用grunt:

grunt --force
GrunFile.js文件内容示例:

module.exports = function(grunt) { // All configuration goes here grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concat: { // Configuration for concatenating files goes here. dist: { src: [ '../js/libs/owl.carousel.js', '../js/libs/jquery.actual.js', '../js/libs/chosen.jquery.js', '../js/libs/jquery.parallax.js', '../js/src/common.js' ], dest: '../js/pro/global.js', }, }, uglify: { build: { src: '../js/pro/global.js', dest: '../js/pro/global.min.js', }, }, imagemin: { dynamic: { files: [{ expand: true, cwd: '../img/src/', src: ['**/*.{png,jpg,gif}'], dest: '../img/pro/' }] } }, compass: { dev: { options: { sassDir: '../sass', cssDir: '../css', fontsDir: '../fonts', imagesDir: '../img/', images: '../img/', javascriptsDir: '../js/pro', //environment: 'development', outputStyle: 'compressed', relativeAssets: true, httpPath: '.', } }, }, watch: { scripts: { files: ['../js/**/**.js'], tasks: ['concat', 'uglify'], options: { spawn: true, }, }, images: { files: ['../img/src/**.{png,jpg,gif}'], tasks: ['imagemin'], options: { spawn: true, } }, compass: { files: ['../**/*.{scss,sass}'], tasks: ['compass:dev'], } }, svgstore: { defaults: { options: { prefix : 'icon-', }, files: { '../img/svg-defs.svg': ['../img/svg/*.svg'] } } }, }); // Where we tell Grunt we plan to use this plug-in. grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-imagemin'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-compass'); grunt.loadNpmTasks('grunt-svgstore'); // Where we tell Grunt what to do when we type "grunt" into the terminal. grunt.registerTask('default', ['concat', 'uglify', /*'imagemin',*/ 'compass', 'svgstore', 'watch']); };
{
"name": "Call Me Maybe",
"version": "0.2.0",
"devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-compass": "^1.0.4",
    "grunt-contrib-concat": "^0.5.1",
    "grunt-contrib-imagemin": "^0.9.4",
    "grunt-contrib-sass": "^0.9.2",
    "grunt-contrib-uglify": "^0.9.2",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-svgstore": "^0.5.0"
  }
}
产生的EPERM错误如下所示:

Running "concat:dist" (concat) task
Warning: Unable to write "../js/pro/global.js" file (Error code: EPERM). Used --force, continuing.

Running "uglify:build" (uglify) task
Warning: Unable to write "../js/pro/global.min.js" file (Error code: EPERM). Used --force, continuing.

Running "compass:dev" (compass) task
Warning: Command failed: /bin/sh: compass: command not found. Used --force, continuing.
Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.

Running "svgstore:defaults" (svgstore) task
Warning: Unable to write "../img/svg-defs.svg" file (Error code: EPERM). Used --force, continuing.

Running "watch" task
Waiting...
有趣的是,还安装了Ruby和Compass,因此它确实符合无根无法写入文件夹问题的理论,但是如何将依赖项核心移动到其他地方(即/usr/local/bin),所以这不是问题?


在El Capitan Betas期间,一些用户建议通过终端启用root,尽管这似乎不再有效,因为错误依然存在,/usr/bin文件夹仍然不允许更改权限。

在/usr/bin上安装非系统软件是一个错误的举动,现在在El Capitan是被禁止的,并且有充分的理由


我不熟悉grunt,但如果你能改用/usr/local/bin,那么可能一切都正常。

对于遇到相同问题的人,我必须取消使用路径:/usr/bin中安装的二进制文件,并在更新路径/usr/local/bin后重新安装。鲁比往往是罪魁祸首。因为我很难找到我所有的ruby安装,所以我最终安装了rbenv来管理我的ruby版本

以下终端命令可能有助于识别有问题的路径:

which ruby
gem environment
gem uninstall [insert gem name here]
[google how to set your paths to /usr/local/bin... (will be in a hidden file)]
gem install [insert gem name here]

我同意,因此我将我的问题部分加粗,问“如何”将它们转移到其他地方,这样就不是问题了。我还想明确指出,我没有否决你的答案,因此请不要否决我的问题。在el capitan事件之后,我在全球gem安装方面遇到了一系列问题,不得不用
sudo gem install-n/usr/local/bin compass将其重新安装到
/usr/local/bin
目录。但我不认识你的错误。是否可能在根目录中全局安装了任何节点依赖项?可能,我确实使用了
sudogem安装-n/usr/local/bin compass
,但没有解决问题。我确实发现,当运行
grunt-v--force
时,一切运行正常,但当每个文件都要写入时,它就无法写入,例如
警告:无法写入“./img/svg defs.svg”文件(错误代码:EPERM)。已使用--强制,继续。
brew安装节点
将npm放入
usr/local/bin
,这样您就可以忘记权限问题。我还建议重新启动以进行恢复,并使用
csrutil disable
关闭SIP。特别是如果您拥有驻留在
usr/local/sbin
免责声明中的公式:如果您非常有安全意识,并且我不对意外的
sudo rm-rf/
检查
brew安装安全rm
负责,我建议您禁用SIP,如果您想非常小心的话。干杯