NPM安装不适用于Maven(错误:找不到模块'../lib/utils/unsupported.js')

时间:2019-01-23 10:09:33

标签: maven npm module

我在前端文件夹的本地“节点”下以及全局安装了节点。当我在终端中运行npm install时,一切正常,但是当我全新安装项目时,以某种方式出现以下错误:

[ERROR] internal/modules/cjs/loader.js:582
[ERROR]     throw err;
[ERROR]     ^
[ERROR] 
[ERROR] Error: Cannot find module '../lib/utils/unsupported.js'
[ERROR]     at Function.Module._resolveFilename      (internal/modules/cjs/loader.js:580:15)
[ERROR]     at Function.Module._load  (internal/modules/cjs/loader.js:506:25)
[ERROR]     at Module.require (internal/modules/cjs/loader.js:636:17)
[ERROR]     at require (internal/modules/cjs/helpers.js:20:18)
[ERROR]     at     /Users/jonathansx/projects/Keyfinder/Backoffice/node/node_modules/npm/bi. n/npm-cli.js:19:21
[ERROR]     at Object.<anonymous>     (/Users/jonathansx/projects/Keyfinder/Backoffice/node/node_modules/npm/b in/npm-cli.js:153:3)
[ERROR]     at Module._compile (internal/modules/cjs/loader.js:688:30)
[ERROR]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
[ERROR]     at Module.load (internal/modules/cjs/loader.js:598:32)
[ERROR]     at tryModuleLoad (internal/modules/cjs/loader.js:537:12)

我正在使用MAC。没有设置Node_Path环境变量,也许与此有关?

这是我的Maven构建配置:

<plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${frontend-maven-plugin.version}</version>
                <executions>
                    <!-- Install our node and npm version to run npm/node scripts-->
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v10.13.0</nodeVersion>
                        </configuration>
                    </execution>
                    <!-- Install all project dependencies -->
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <!-- optional: default phase is "generate-resources" -->
                        <phase>generate-resources</phase>
                        <!-- Optional configuration which provides for running any npm command -->
                        <configuration>
                        <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <!-- Build and minify static files -->
                    <execution>
                        <id>npm run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                    <!-- Run Unit tests with Jest -->
                    <execution>
                        <id>npm run test:unit</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <arguments>run test:unit</arguments>
                        </configuration>
                    </execution>
                    <!-- Run End2End tests with Nightwatch -->
                    <!--
                    <execution>
                    <id>npm run test:e2e</id>
                    <goals>
                        <goal>npm</goal>
                    </goals>
                    <phase>test</phase>
                    <configuration>
                          <arguments>run test:e2e</arguments>                        </configuration>
                    </execution>
                    -->
                </executions>
            </plugin>

我尝试过的事情:
-通过brew重新安装节点
-删除了node_modules,并通过终端安装了npm

1 个答案:

答案 0 :(得分:0)

我修复了它: 1.删​​除节点文件夹 2.删除node_modules 3.删除package-lock.json 4.运行全新安装