我有一个旧的AngularJS(1)应用程序曾经开始很好。
昨天升级我的依赖项后,module
和require
个对象(以及其他对象)现在未定义。
// Generated on 2014-10-21 using generator-angular 0.9.8
'use strict';
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
...
}
以下是我的bower.json
文件内容:
{
"name": "nitro-project",
"version": "0.0.0",
"dependencies": {
"angular": "*",
"json3": "*",
"es5-shim": "*",
"stacktrace": "*",
"firebase": "*",
"angular-resource": "*",
"angular-cookies": "*",
"angular-sanitize": "*",
"angular-animate": "*",
"angular-touch": "*",
"angular-route": "*",
"angular-ui-router": "*",
"angular-translate": "*",
"angular-base64": "*",
"angular-bootstrap": "*",
"angular-utils-pagination": "*",
"angular-ui-utils": "*",
"angular-file-upload": "*",
"a0-angular-storage": "*",
"sockjs": "*",
"stomp-websocket": "*"
},
"devDependencies": {
"angular-mocks": "*",
"angular-scenario": "*",
"karma-jasmine": "*"
},
"appPath": "app",
"resolutions": {
"es5-shim": "*",
"angular": "*",
"angular-bootstrap": "*",
"angular-mocks": "*"
}
}
package.json
文件内容:
{
"name": "nitroproject",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "*",
"grunt-autoprefixer": "*",
"grunt-concurrent": "*",
"grunt-contrib-clean": "*",
"grunt-contrib-concat": "*",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-copy": "*",
"grunt-contrib-cssmin": "*",
"grunt-contrib-htmlmin": "*",
"grunt-contrib-imagemin": "*",
"grunt-contrib-jshint": "*",
"grunt-contrib-uglify": "*",
"grunt-contrib-watch": "*",
"grunt-filerev": "*",
"grunt-google-cdn": "*",
"grunt-karma": "*",
"grunt-newer": "*",
"grunt-ng-annotate": "*",
"grunt-ng-constant": "*",
"grunt-svgmin": "*",
"grunt-usemin": "*",
"grunt-wiredep": "*",
"jasmine-core": "*",
"jshint-stylish": "*",
"karma": "*",
"karma-chrome-launcher": "*",
"karma-jasmine": "*",
"karma-phantomjs-launcher": "*",
"load-grunt-tasks": "*",
"serve-static": "^1.11.2",
"time-grunt": "*"
},
"engines": {
"node": ">=6.8.1"
},
"scripts": {
"test": "grunt test"
}
}
我正在运行节点6.8.1
。
没有过时的依赖项:
[stephane@stephane-ThinkPad-X301 nitro-project]
$ npm outdated
[stephane@stephane-ThinkPad-X301 nitro-project]
控制台日志显示了大量此类行:
Running "newer:jshint:all" (newer) task
Running "jshint:all" (jshint) task
Gruntfile.js
line 2 col 1 Use the function form of "use strict".
line 4 col 1 'module' is not defined.
line 7 col 3 'require' is not defined.
line 10 col 3 'require' is not defined.
line 12 col 21 'require' is not defined.
line 16 col 10 'require' is not defined.
line 147 col 19 'require' is not defined.
答案 0 :(得分:0)
在项目目录中,我会尝试:
npm uninstall
npm install -g grunt-cli
npm install
您可能需要全新安装依赖项(特别是Grunt)。如果没有,在进行更多故障排除之前,它值得一试。