0

I am autoconfiguring the CodeBuild for my Spring boot + Angular 4 project, where i use maven-frontend-plugin to install node , npm. Since it installs them locally my ng build is throwing an error like below. Any help?

[INFO] > ng build --prod --no-aot --base-href --allow-root
[ERROR] sh: 1: ng: Permission denied

here is my pom part

<plugin>
     <groupId>com.github.eirslett</groupId>
     <artifactId>frontend-maven-plugin</artifactId>
     <version>1.6</version>
     <configuration>
        <workingDirectory>${project.basedir}/src/main/resources/ui/</workingDirectory>
    </configuration>
     <executions>
       <execution>
         <id>install node and npm</id>
         <goals>
           <goal>install-node-and-npm</goal>
         </goals>
         <configuration>
           <nodeVersion>v9.0.0</nodeVersion>               
         </configuration>
       </execution>

       <execution>
         <id>npm install</id>
         <goals>
           <goal>npm</goal>
         </goals>
         <configuration>
           <arguments>install -g</arguments>
         </configuration>
       </execution>

       <execution>
         <id>prod</id>
         <goals>
           <goal>npm</goal>
         </goals>
         <configuration>
           <arguments>run-script prod</arguments>
         </configuration>
         <phase>generate-resources</phase>
       </execution>
     </executions>
   </plugin>     
user1058913
  • 321
  • 1
  • 4
  • 20

2 Answers2

2

This is why committing the node_modules folder to a repo can be a bad idea. You pulled it, permissions and all. Just wipe out the folder and reinstall, or update the permissions recursively to the folder.

0

Looks like your current user does not have the permission to run ng.

Try:sudo ng build

Or run which ng to get the path of angular-cli and use chmod to get permission for your current user.

  • Have tried that too, it throws the below error [INFO] > sudo ng build --prod --no-aot --base-href --allow-root [INFO] [ERROR] sudo: ng: command not found – user1058913 Nov 03 '17 at 21:11
  • Did you run `npm install` in the folder where the package.json is located before you run ng build? Looks like it is not complaining about permission anymore. Instead, it is complaining about not finding the ng command – Yuxiang Chen Nov 03 '17 at 21:24
  • i am using frontend-maven-plugin which install node , nom & its packages – user1058913 Nov 03 '17 at 21:32
  • which means 'ng' is installed locally to your project. So if you want to run 'ng', either you specify the full path to it. Or you could just install it globally. – Yuxiang Chen Nov 03 '17 at 21:37
  • this plugin installs it locally , that seems to be the issue, no option to install it globally – user1058913 Nov 03 '17 at 21:44
  • Then try to specify the full path to `ng`. If it's still not working, `npm install -g @angular/cli` will install `ng` globally. – Yuxiang Chen Nov 03 '17 at 21:47
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/158194/discussion-between-yuxiang-chen-and-user1058913). – Yuxiang Chen Nov 03 '17 at 21:53