我正在观看youtube视频,将VueJS集成到Asp.Net Core 2.2 MVC应用程序中,我对VueJS完全陌生。
源代码为:https://github.com/dotnettec/Integrating-Vue-js-with-ASP.Net-Core-MVC
添加package.json
和webpack.config.js
后,当我尝试运行npm run build
时,它没有在bundle
中生成wwwroot
文件夹,并且出现错误:< / p>
PM> npm run build
> vue-mvc@1.0.0 build C:\Workspace\AspNetCoreWithVueJS\AspNetCoreWithVueJS\AspNetCoreWithVueJS
> cross-env NODE_ENV = production webpack --progress --hide-modules
npm : 'cross-env' is not recognized as an internal or external command,
At line:1 char:1
+ npm run build
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ('cross-env' is ...ternal command,:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
operable program or batch file.
npm
ERR!
code
ELIFECYCLE
npm
ERR!
errno
1
npm
ERR!
vue-mvc@1.0.0 build: `cross-env NODE_ENV = production webpack --progress --hide-modules`
npm
ERR!
Exit status 1
npm
ERR!
npm
ERR!
Failed at the vue-mvc@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm
ERR!
A complete log of this run can be found in:
npm
ERR!
C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-11-12T06_45_04_074Z-debug.log
您能找到如何使它与上面的链接一起工作吗?
节点版本:v10.15.3 npm版本:6.4.1
答案 0 :(得分:1)
也许可以为该主题提供一些见识。
npm run“ build”通过package.json中定义的命令行在脚本对象处调用脚本:
"scripts": {
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
cross-env命令似乎未被识别为命令,因此,我建议您从npm安装Crossenv(如果尚未安装) 根据您的操作系统,可能需要执行其他步骤。
npm install --save-dev cross-env
答案 1 :(得分:0)
通常,这意味着您需要在构建应用程序之前运行npm install。
尝试这种方式:
$ npm install
$ npm run build