Programing

"치명적인 오류 : 로컬 그런트를 찾을 수 없습니다."

lottogame 2020. 10. 23. 07:32
반응형

"치명적인 오류 : 로컬 그런트를 찾을 수 없습니다." "grunt"명령을 실행할 때


다음 명령으로 grunt를 제거했습니다.

npm uninstall -g grunt

그런 다음 다음 명령으로 다시 grunt를 설치했습니다.

npm install -g grunt-cli

다음 링크를 방문하십시오 : https://npmjs.org/package/grunt-html

위의 grunt 플러그인을 사용하고 싶습니다

그러나 grunt 명령을 실행하면 다음과 같은 오류가 발생합니다.

D:\nodeJS\node_modules\grunt-html>grunt
grunt-cli: The grunt command line interface. (v0.1.6)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:
http://gruntjs.com/getting-started

모든 것은 gruntjs.com에 아주 잘 설명되어 있습니다 .

grunt-cli를 설치해도 grunt 태스크 러너는 설치되지 않습니다! grunt CLI의 작업은 간단합니다. Gruntfile 옆에 설치된 grunt 버전을 실행합니다. 이를 통해 여러 버전의 grunt를 동일한 시스템에 동시에 설치할 수 있습니다.

따라서 프로젝트 폴더에 최신 grunt 버전 을 설치해야합니다 .

npm install grunt --save-dev

옵션 --save-devpackage.json에 dev-dependency추가 grunt됩니다 . 이렇게하면 종속성을 쉽게 다시 설치할 수 있습니다.


프로젝트 폴더에 grunt를 설치해야합니다

  1. package.json 생성

    $ npm init
    
  2. 이 프로젝트를 위해 grunt를 설치하면 node_modules/. --save-dev는이 모듈을 package.json의 devDependency에 추가합니다.

    $ npm install grunt --save-dev
    
  3. 그런 다음 gruntfile.js를 만들고 실행하십시오.

    $ grunt 
    

package.json파일 에 그런트를 추가해야한다고 생각 합니다. 이 링크를 참조하십시오 .


64 비트 Windows OS에 32 비트 버전의 Node를 설치했기 때문에 Windows grunt에서이 문제가 발생했습니다. 구체적으로 64 비트 버전을 설치했을 때 작동하기 시작했습니다.


오늘 Windows 32 비트, 노드 0.10.25 및 그런트 0.4.5에서 동일한 문제가 발생했습니다.

나는 몇 가지 추가 단계로 동호의 대답을 따랐다 . 오류를 해결하는 데 사용한 단계는 다음과 같습니다.

1) package.json 생성

$ npm init

2)이 프로젝트에 grunt를 설치하면 node_modules / 아래에 설치됩니다. --save-dev는이 모듈을 package.json의 devDependency에 추가합니다.

$ npm install grunt --save-dev

3) 다음 gruntfile.js과 같은 샘플 코드로 를 만듭니다 .

module.exports = function(grunt) {

  grunt.initConfig({
    jshint: {
      files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
      options: {
        globals: {
          jQuery: true
        }
      }
    },
    watch: {
      files: ['<%= jshint.files %>'],
      tasks: ['jshint']
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['jshint']);

};

여기에, src/**/*.js그리고 test/**/*.js프로젝트에서 사용하는 실제 JS 파일의 경로해야한다

4) 달리기 npm install grunt-contrib-jshint --save-dev

5) 달리기 npm install grunt-contrib-watch --save-dev

6) 달리기 $ grunt

참고 : concat, uglify 등과 같은 공통 패키지가 필요한 경우 npm install4 및 5 단계에서 jshint를 설치하고 감시하는 방식으로을 통해 해당 모듈을 추가해야합니다.


존재하는 프로젝트라면 npm install을 실행해야합니다.

guntjs 시작하기 2 단계.


This solved the issue for me. I mistakenly installed grunt using:

sudo npm install -g grunt --save-dev

and then ran the following command in the project folder:

npm install

This resulted in the error seen by the author of the question. I then uninstalled grunt using:

sudo npm uninstall -g grunt

Deleted the node_modules folder. And reinstalled grunt using:

npm install grunt --save-dev

and running the following in the project folder:

npm install

For some odd reason when you global install grunt using -g and then uninstall it, the node_modules folder holds on to something that prevents grunt from being installed locally to the project folder.

참고URL : https://stackoverflow.com/questions/15483735/fatal-error-unable-to-find-local-grunt-when-running-grunt-command

반응형