无法使用 Node 安装任何软件包.js



我是Ionic,Cordova和Node.js的绝对新手。

我对 Node.js 有以下问题:

我从一位用离子和科尔多瓦创建的同事那里得到了一个项目。该应用程序本身也在运行,对于特殊客户,我们已经调整了设计。我的想法是,它很快就完成了。我将 GIT 中的分支更改为相应的项目并想这样做。不幸的是,我收到了无数的错误消息和警告,这是我在以前的项目中没有的。

我卸载了 Node.js并完全重新安装了它,不幸的是没有任何变化。我无法卸载或安装任何软件包。我总是收到这个永远很长的错误消息,我不知道问题到底是什么。卸载离子和科尔多瓦也不起作用,相同的错误消息。下面是我的 Node.js、Ionic 和 cordova 版本的列表,以及错误消息的开头和结尾。

Console:gitproject user$ git branch
* development
master
Console:gitproject user$ ionic cordova build
? What platform would you like to build (android, ios): ios
> ionic-app-scripts build --target cordova --platform ios
[08:44:43]  ionic-app-scripts 3.2.3 
[08:44:43]  build dev started ... 
[08:44:43]  clean started ... 
[08:44:43]  clean finished in 24 ms 
[08:44:43]  copy started ... 
[08:44:43]  deeplinks started ... 
[08:44:44]  deeplinks finished in 593 ms 
[08:44:44]  transpile started ... 
[08:44:56]  typescript: src/app/app.component.ts, line: 34 
Cannot find name 'Globalization'. 
L33:            private translate: TranslateService,
L34:            private globalization: Globalization) {
L35:  platform.ready().then(() => {
[08:44:56]  ionic-app-script task: "build" 
[08:44:56]  Error: Failed to transpile program 
Error: Failed to transpile program
at new BuildError (/path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at /path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/transpile.js:159:20
at new Promise (<anonymous>)
at transpileWorker (/path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/transpile.js:107:12)
at Object.transpile (/path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/transpile.js:64:12)
at /path/to/project/gitproject/node_modules/@ionic/app-scripts/dist/build.js:109:82
[ERROR] An error occurred while running subprocess ionic-app-scripts.
ionic-app-scripts build --target cordova --platform ios exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Console:gitproject user$ ionic cordova plugin add cordova-plugin-globalization
> cordova plugin add cordova-plugin-globalization --save
Installing "cordova-plugin-globalization" for ios
Unable to load PlatformApi from platform. Error: Cannot find module 'unorm'
Require stack:
- /path/to/project/gitproject/platforms/ios/cordova/Api.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/plugman.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/cordova-lib.js
- /usr/local/lib/node_modules/cordova/src/help.js
- /usr/local/lib/node_modules/cordova/src/cli.js
- /usr/local/lib/node_modules/cordova/bin/cordova
Failed to install 'cordova-plugin-globalization': Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('The platform "ios" does not appear to be a valid ' +
'cordova platform. It is missing API.js. ios not ' +
'supported.')
at CordovaEventEmitter.emit (events.js:185:17)
at CordovaEventEmitter.emit (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/events.js:69:22)
at Object.getPlatformApiFunction (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js:384:20)
at Object.getPlatformApi (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js:55:32)
at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:580:29)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:349:28
at processTicksAndRejections (internal/process/task_queues.js:89:5)
Unhandled error. ('The platform "ios" does not appear to be a valid ' +
'cordova platform. It is missing API.js. ios not ' +
'supported.')
Console:gitproject user$ npm install @ionic-native/globalization
> fsevents@1.2.4 install /path/to/project/gitproject/node_modules/fsevents
> node install
node-pre-gyp WARN Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.4/fse-v1.2.4-node-v72-darwin-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for fsevents@1.2.4 and node@12.2.0 (node-v72 ABI, unknown) (falling back to source compile with node-gyp) 
...
...
...
...
10 warnings and 8 errors generated.
make: *** [Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/path/to/project/gitproject/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:200:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/bin/node" "/path/to/project/gitproject/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /path/to/project/gitproject/node_modules/node-sass
gyp ERR! node -v v12.3.1
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.9.0 postinstall 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!     /path/to/user/folder/.npm/_logs/2019-05-27T08_04_02_672Z-debug.log

这是上述错误日志中的版本

2653 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
2654 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 install: `node install`
2654 warn optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
2655 verbose optional SKIPPING OPTIONAL DEPENDENCY:
2655 verbose optional Failed at the fsevents@1.2.4 install script.
2655 verbose optional SKIPPING OPTIONAL DEPENDENCY: This is probably not a problem with npm. There is likely additional logging output above.
2656 verbose stack Error: node-sass@4.9.0 postinstall: `node scripts/build.js`
2656 verbose stack Exit status 1
2656 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
2656 verbose stack     at EventEmitter.emit (events.js:200:13)
2656 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
2656 verbose stack     at ChildProcess.emit (events.js:200:13)
2656 verbose stack     at maybeClose (internal/child_process.js:1021:16)
2656 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
2657 verbose pkgid node-sass@4.9.0
2658 verbose cwd /Users/premox/Documents/projects/gitproject
2659 verbose Darwin 18.6.0
2660 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "uninstall" "sass"
2661 verbose node v12.3.1
2662 verbose npm  v6.9.0
2663 error code ELIFECYCLE
2664 error errno 1
2665 error node-sass@4.9.0 postinstall: `node scripts/build.js`
2665 error Exit status 1
2666 error Failed at the node-sass@4.9.0 postinstall script.
2666 error This is probably not a problem with npm. There is likely additional logging output above.
2667 verbose exit [ 1, true ]
Console:gitproject user$ node -v
v12.3.1
Console:gitproject user$ npm -v
6.9.0

有人可以向我解释此错误消息吗?

为了正确设置项目,您可以做几件事。

  1. 检查节点,离子和科尔多瓦是否正确安装。

  2. 完全删除节点模块文件夹,然后运行以下命令:-

    npm 安装

这将安装项目中的所有依赖项。

  1. 如果上述不起作用,那么您可以尝试,与 Ashok 提到的相同步骤来解决:-

    npm install @ionic/app-scripts@latest --save-dev

如果您有任何问题,请告诉我。

最新更新