我已将node_modules文件夹移至项目的父文件夹,以便能够在项目之间共享它。然后,当我在项目文件夹中执行“ npm run dev”命令时,出现此错误:
E:\NodeApps\MyApp>npm run dev > testapp@1.0.0 dev E:\NodeApps\MyApp > cross-env NODE_ENV=development webpack-dev-server --open --hot 'cross-env' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! testapp@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the testapp@1.0.0 dev script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install? npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\me\AppData\Roaming\npm-cache\_logs\2019-05-27T23_51_07_151Z-debug.log
在移动node_modules之前,解决方案运行良好。我已经阅读到运行时将在目录树中搜索以找到node_modules。
在不再次移动node_modules的情况下使项目工作的步骤是什么?
答案 0 :(得分:0)
每个项目都有自己的package.json
和dependencies
和devdependencies
,这是特定项目所必需的,并且复制node_modules不会更改路径或修改相关内容。在“环境变量”中设置路径(已完成然后保留该路径)。
运行此命令:
npm install