我正在尝试在新机器上运行grunt,但它无法编译。
我收到的错误是:
Running "requirejs:compile" (requirejs) task { [Error: Error: ERROR: module path does not exist: /Volumes/Users/dtdtdg/assets/js/src/../../../bower_components/almond/almond.js for module named: ../../../bower_components/almond/almond. Path is relative to: /Volumes/Users/dtdtdg
at /Volumes/Users/dtdtdg/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:26824:35 ] originalError: [Error: ERROR: module path does not exist: /Volumes/Users/dtdtdg/assets/js/src/../../../bower_components/almond/almond.js for module named: ../../../bower_components/almond/almond. Path is relative to: /Volumes/Users/dtdtdg] }
我运行sudo npm install -g bower-installer
和sudo npm install -g bower
只是为了确保我没有错过这台机器上的任何软件包。仍然没有运气。
我的grunt文件如下:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', [
'copy',
'sass',
'requirejs'
]);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
main: {
cwd: 'bower_components/foundation/css/',
src: '*',
dest: 'assets/css/vendor/foundation/',
expand: true,
rename: function(dest, src) {
return (dest + src).replace('.css', '.scss');
}
}
},
requirejs: {
compile: {
options: {
baseUrl: 'assets/js/src',
include: ['require-main'],
mainConfigFile: 'assets/js/src/require-main.js',
name: '../../../bower_components/almond/almond',
out: 'assets/js/build/app.js'
}
}
},
sass: {
dist: {
options: {
style: 'compressed'
},
files: {
'assets/css/build/styles.css': 'assets/css/src/manifest.scss'
}
}
},
watch: {
css: {
files: ['assets/css/src/**/*.scss'],
tasks: ['sass'],
options: {
spawn: false
}
}
//scripts:{
//files:['assets/js/src/**/*.js'],
//tasks:['requirejs']
//}
}
});
};
好的我现在通过运行bower install almond
来解决此问题,但现在出现以下错误:
Running "requirejs:compile" (requirejs) task
Error: ENOENT, no such file or directory '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js'
In module tree:
require-main
{ [Error: Error: ENOENT, no such file or directory '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js'
In module tree:
require-main
at Object.fs.openSync (fs.js:438:18)
]
originalError:
{ [Error: ENOENT, no such file or directory '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js']
errno: 34,
code: 'ENOENT',
path: '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js',
syscall: 'open',
fileName: '/Volumes/Users/dtdtdg/assets/js/src/routers/router.js',
moduleTree: [ 'require-main' ] } }
答案 0 :(得分:0)
我的错 - 我重命名了资产/ js / src / routers / router.js。