我有一个旧的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"
}
}我正在运行node 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.发布于 2017-02-18 05:33:55
在您的项目目录中,我会尝试:
npm uninstall
npm install -g grunt-cli
npm install您可能需要全新安装您的依赖项(尤其是Grunt)。如果不是,在进行更多的故障排除之前,值得一试。
https://stackoverflow.com/questions/42301122
复制相似问题