以上就是给各位分享错误:找不到模块“@ionic/app-scripts”,其中也会对错误找不到指定的模块进行解释,同时本文还将给你拓展./components/Avatar.tsx错误:找不到模块“
以上就是给各位分享错误:找不到模块“ @ ionic / app-scripts”,其中也会对错误找不到指定的模块进行解释,同时本文还将给你拓展./components/Avatar.tsx 错误:找不到模块“@babel/preset-stage-0”、angular – Ionic 2 – 运行时错误找不到模块“.”、Angular 和 Typescript:找不到名称 - 错误:找不到名称、angularjs – 错误:找不到模块’@ ionic/app-scripts’等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- 错误:找不到模块“ @ ionic / app-scripts”(错误找不到指定的模块)
- ./components/Avatar.tsx 错误:找不到模块“@babel/preset-stage-0”
- angular – Ionic 2 – 运行时错误找不到模块“.”
- Angular 和 Typescript:找不到名称 - 错误:找不到名称
- angularjs – 错误:找不到模块’@ ionic/app-scripts’
错误:找不到模块“ @ ionic / app-scripts”(错误找不到指定的模块)
我是Ionic的新手。我遵循Ionic文档“入门”,创建了一个名为“ super”的项目示例。问题是,当我ionicserve
在项目目录中运行命令行时,它引发了错误Error: Cannot find module ''@ionic/app-scripts''
答案1
小编典典当前与节点6和7兼容的应用程序脚本。安装了节点8后,请卸载并安装节点6稳定版本。解决了这个错误,现在我可以使用离子3,角4了。照顾自己!
./components/Avatar.tsx 错误:找不到模块“@babel/preset-stage-0”
不知道为什么会出现这个错误
这是我的 webpack,它按预期工作 另外,提前道歉,因为我已经做了大量优化以减少包大小
Webpack.config.base.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack');
const CopyPlugin = require("copy-webpack-plugin");
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
const {WebpackManifestPlugin} = require('webpack-manifest-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const PurifyCssPlugin = require('purifycss-webpack');
const glob = require("glob");
module.exports = {
target: 'web',stats: 'verbose',output: {
path: __dirname + '/dist',filename: '[name].[hash].bundle.js'
},resolve: {
extensions: ['.js','.jsx']
},module: {
rules: [
{
test: /\.(js|jsx)$/,exclude: /node_modules/,use: {
loader: "babel-loader"
}
},{
test: /\.html$/,use: [
{
loader: "html-loader"
}
]
},{
test: /\.css$/,use: [{
loader: MiniCssExtractPlugin.loader,options: {
publicPath: './'
}
},'css-loader']
},{
test: /\.scss$/,'css-loader','sass-loader']
},{
test: /\.(png|svg|jpg|gif)$/,use: [
'file-loader',{
loader: 'image-webpack-loader',options: {
bypassOnDebug: true,// webpack@1.x
disable: true,// webpack@2.x and newer
mozjpeg: {
progressive: true,},optipng: {
enabled: false,pngquant: {
quality: [0.65,0.90],speed: 4
},gifsicle: {
interlaced: false,}
]
}
]
},plugins: [
new CopyPlugin({
patterns: [
{from: "icons",to: "icons"},{from: "./manifest.webmanifest",to: ""},{from: "./.htaccess",{from: "./robots.txt",to: ""}
],}),new MiniCssExtractPlugin({
filename: "[name].[hash].css"
}),new HtmlWebpackPlugin({
template: "./src/app/index.html",favicon: "./src/assets/image/favicon.png",inject: true,minify: {
removeComments: true,collapseWhitespace: true
}
}),new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname,'./src/app/serviceWorker/serviceWorkerInit.js'),new WebpackManifestPlugin({
fileName: 'asset-manifest.json',// Not to confuse with manifest.json
}),new ESLintPlugin({files: './src/app/app.js'}),new PurifyCssPlugin({
paths: [
...(glob.sync(`./src/app/*.html`)),...(glob.sync(`./src/app/**/*.jsx`)),...(glob.sync(`./dist/*.html`))
],styleExtensions: ['.css','.scss'],moduleExtensions: [".html"],verbose: true,purifyOptions: {
info: true,minify: true,whitelist: ["*purify*"]
},})
]
};
Webpack.config.prod.js
const merge = require('webpack-merge');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const webpackBaseConfiguration = require('./webpack.config.base.js');
const TerserPlugin = require('terser-webpack-plugin')
const webpack = require('webpack');
const GLOBALS = {
'process.env.NODE_ENV': JSON.stringify('production'),__DEV__: false
};
module.exports = merge(webpackBaseConfiguration,{
mode: 'production',entry: [
'@babel/polyfill','./src/app/app.jsx'
],devServer: {
contentBase: './dist'
},optimization: {
splitChunks: {
chunks: 'all',minSize: 20000,maxSize: 0,minChunks: 2,maxAsyncRequests: 30,maxInitialRequests: 30,enforceSizeThreshold: 50000,cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,priority: -10,reuseExistingChunk: true
},default: {
minChunks: 2,priority: -20,reuseExistingChunk: true
}
}
},usedExports: true,minimizer: [
new TerserPlugin({
parallel: true,terserOptions: {
ecma: 6,new OptimizeCSSAssetsPlugin()
]
},plugins: [
new webpack.DefinePlugin(GLOBALS),new CompressionPlugin({
algorithm: 'gzip',minRatio: Number.MAX_SAFE_INTEGER
}),new CompressionPlugin({
filename: "[path].br",algorithm: "brotliCompress",test: /\.(js|css|html|svg|png|svg|jpg|gif)$/,deleteOriginalAssets: false,minRatio: Number.MAX_SAFE_INTEGER
})
]
});
Webpack.config.dev.js
const merge = require('webpack-merge');
const webpackBaseConfiguration = require('./webpack.config.base');
const webpack = require('webpack');
module.exports = merge(webpackBaseConfiguration,{
mode: 'development',output: {
publicPath: '/'
},devServer: {
contentBase: './src',historyApiFallback: true
},devtool: 'cheap-module-eval-source-map','webpack-hot-middleware/client?reload=true',plugins: [
/*For hot deployment*/
new webpack.HotModuleReplacementPlugin()
]
});
package.json
{
"name": "Sample","version": "1.0.0","description": "React app","scripts": {
"clean": "rimraf dist","deploy": "node deploy","build:prod:deploy": "npm run clean && webpack --mode production --config webpack.config.prod.js && node deploy","build:prod": "npm run clean && webpack --mode production --config webpack.config.prod.js","build:dev": "webpack-dev-server --mode development --config webpack.config.dev.js --open --hot","start": "npm run build && npm run deploy","build": "npm run clean && webpack --mode production --config webpack.config.prod.js && npm run deploy"
},"engines": {
"node": "14.x","npm": "6.x"
},"keywords": [],"author": "","license": "ISC","devDependencies": {
"@babel/cli": "^7.12.1","@babel/core": "^7.2.2","@babel/node": "^7.2.2","@babel/plugin-proposal-class-properties": "^7.3.0","@babel/polyfill": "^7.2.5","@babel/preset-env": "^7.2.0","@babel/preset-react": "^7.0.0","@babel/register": "^7.0.0","@gfx/zopfli": "^1.0.15","babel-eslint": "^10.1.0","babel-loader": "^8.0.4","brotli-webpack-plugin": "^1.1.0","compression-webpack-plugin": "^2.0.0","copy-webpack-plugin": "6.2.1","css-loader": "^2.1.0","eslint": "^7.18.0","eslint-webpack-plugin": "^2.4.1","file-loader": "^3.0.1","ftp-deploy": "^2.4.0","glob": "^7.1.6","html-loader": "^0.5.5","html-webpack-plugin": "^3.2.0","image-minimizer-webpack-plugin": "^1.0.0","image-webpack-loader": "^7.0.1","imagemin-gifsicle": "^7.0.0","imagemin-jpegtran": "^7.0.0","imagemin-optipng": "^8.0.0","imagemin-svgo": "^8.0.0","mini-css-extract-plugin": "^0.5.0","node-sass": "^4.14.1","optimize-css-assets-webpack-plugin": "^5.0.1","purify-css": "^1.2.5","purifycss-webpack": "^0.7.0","rimraf": "^2.6.3","sass-loader": "^7.1.0","serviceworker-webpack-plugin": "^1.0.1","terser-webpack-plugin": "4.2.3","uglifyjs-webpack-plugin": "^2.1.1","webpack": "^4.40.0","webpack-cli": "^3.1.2","webpack-dev-middleware": "^3.5.2","webpack-dev-server": "^3.11.0","webpack-ftp-upload-plugin": "^1.0.3","webpack-hot-middleware": "^2.24.3","webpack-manifest-plugin": "^3.0.0","webpack-merge": "^4.2.1","workbox-cacheable-response": "^6.0.2","workbox-expiration": "^6.0.2","workbox-routing": "^6.0.2","workbox-strategies": "^6.0.2","workbox-webpack-plugin": "^6.0.2","zlib": "^1.0.5"
},"dependencies": {
"axios": "^0.19.0","bootstrap": "^4.5.0","react": "^16.8.1","react-dom": "^16.8.1","react-lazy-load-image-component": "^1.5.1","react-paginate": "^6.5.0","react-redux": "^7.2.2","react-router": "^4.3.1","react-router-dom": "^4.3.1","redux": "^4.0.5","redux-immutable-state-invariant": "^2.1.0","redux-thunk": "^2.3.0"
}
}
angular – Ionic 2 – 运行时错误找不到模块“.”
ionic serve
我不确定这个错误源于何处.我仔细地仔细检查了我的TypeScript文件中所有导入的损坏路径.我什么都没找到.
应用程序工作和不工作之间唯一的变化是添加了一个用于保存Google地图位置数据的新界面.
但是我不知道这是如何相关的,它必须是构建过程中的其他东西.
app.modules.ts
import { NgModule,ErrorHandler } from '@angular/core'; import { IonicApp,IonicModule,IonicErrorHandler } from 'ionic-angular'; import { IonicStorageModule } from '@ionic/storage'; import { MyApp } from './app.component'; import { Geolocation } from '@ionic-native/geolocation'; import { Place } from '../model/place.model'; import { AboutPage } from '../pages/about/about'; import { ContactPage } from '../pages/contact/contact'; import { NewPlacePage } from '../pages/new-place/new-place'; import { PlacePage } from '../pages/place/place'; import { HomePage } from '../pages/home/home'; import { TabsPage } from '../pages/tabs/tabs'; import { ActivePage } from '../pages/active/active'; import { PlacesService } from '../services/places.service'; import { ConnectivityService } from '../providers/connectivity-service'; import {AgmCoreModule } from 'angular2-google-maps/core' @NgModule({ declarations: [ MyApp,AboutPage,ContactPage,HomePage,TabsPage,ActivePage,NewPlacePage,PlacePage ],imports: [ IonicModule.forRoot(MyApp),IonicStorageModule.forRoot(),AgmCoreModule.forRoot({ apiKey: 'hiddenforstackoverflow' }) ],bootstrap: [IonicApp],entryComponents: [ MyApp,providers: [{provide: ErrorHandler,useClass: IonicErrorHandler},ConnectivityService,PlacesService,Storage] }) export class AppModule {}
places.service.ts
import { Injectable } from '@angular/core'; import { Storage } from '@ionic/storage'; import { Place } from '../model/place.model'; @Injectable() export class PlacesService { private places: Place[] = []; constructor(private storage: Storage) { } addplace(place: Place) { this.places.push(place); console.log(this.places); this.storage.set('places',this.places); } getPlaces() { return this.storage.get('places') .then( (places) => { this.places = places == null ? [] : places; console.log(this.places); console.log(places); return this.places.slice(); }); } }
newplace.ts
import { Component,Injectable } from '@angular/core'; import { NavController,NavParams } from 'ionic-angular'; import { PlacesService } from '../../services/places.service'; import { Geofence,Geolocation,SMS } from 'ionic-native'; @Component({ selector: 'page-new-place',templateUrl: 'new-place.html' }) export class NewPlacePage { location: { lat: number,lng: number } = { lat: 0,lng: 0 }; constructor(private placesService: PlacesService,private navCtrl: NavController) { } onLocateUser() { Geolocation.getCurrentPosition() .then( (location) => { console.log('Location successful') this.location.lat = location.coords.latitude; this.location.lng = location.coords.longitude } ) } onAddplace(value: { title: string }) { console.log(value); this.placesService.addplace({ title: value.title,location: this.location }); this.navCtrl.pop(); } }
place.model.ts
export interface Place { title: string; location: { lat: number,lng: number } }
离子版本
Ionic Framework: 2.2.0 Ionic Native: ^2.4.1 Ionic App Scripts: 1.2.5 Angular Core: 2.4.8 Angular Compiler CLI: 2.4.8 Node: 7.7.4 OS Platform: Windows 10 Navigator Platform: Win32 User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/56.0.2924.87 Safari/537.36
的package.json
{ "name": "ionic-hello-world","author": "Ionic Framework","homepage": "http://ionicframework.com/","private": true,"scripts": { "clean": "ionic-app-scripts clean","build": "ionic-app-scripts build","ionic:build": "ionic-app-scripts build","ionic:serve": "ionic-app-scripts serve" },"dependencies": { "@angular/common": "2.4.8","@angular/compiler": "2.4.8","@angular/compiler-cli": "2.4.8","@angular/core": "2.4.8","@angular/forms": "2.4.8","@angular/http": "2.4.8","@angular/platform-browser": "2.4.8","@angular/platform-browser-dynamic": "2.4.8","@angular/platform-server": "2.4.8","@ionic-native/core": "^3.4.4","@ionic-native/geolocation": "^3.4.4","@ionic/storage": "2.0.0","@types/google-maps": "^3.2.0","angular2-google-maps": "^0.17.0","ionic-angular": "2.2.0","ionic-native": "^2.4.1","ionicons": "3.0.0","typescript": "2.0.9","rxjs": "5.0.1","sw-toolBox": "3.4.0","zone.js": "0.7.2" },"devDependencies": { "@ionic/app-scripts": "^1.2.5","typescript": "2.0.9" },"cordovaPlugins": [ "cordova-plugin-whitelist","cordova-plugin-console","cordova-plugin-device","cordova-plugin-statusbar","cordova-plugin-splashscreen","ionic-plugin-keyboard" ],"cordovaPlatforms": [],"description": "ionic-boiler: An Ionic project" }
任何人都可以提供有关如何进一步调试的建议吗?我应该调试polyfils.ts文件吗?
解决方法
问题1:你必须删除这个旧模块“ionic-native”:“^ 2.4.1”,然后运行npm i
问题2:您需要在providers数组(app.module.ts)中注入Geolocation.您必须使用最新的离子本机(“@ ionic-native / core”:“^ 3.4.4”)执行此操作.
你可以在这里阅读更多相关信息:Ionic Native.
Angular 和 Typescript:找不到名称 - 错误:找不到名称
我将 Angular(版本 2)与 TypeScript(版本 1.6)一起使用,当我编译代码时出现以下错误:
Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/change_detection/parser/locals.d.ts(4,42): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(1,25): Error TS2304: Cannot find name 'MapConstructor'.
node_modules/angular2/src/core/facade/collection.d.ts(2,25): Error TS2304: Cannot find name 'SetConstructor'.
node_modules/angular2/src/core/facade/collection.d.ts(4,27): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(4,39): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(7,9): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(8,30): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(11,43): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(12,27): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(14,23): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(15,25): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/collection.d.ts(94,41): Error TS2304: Cannot find name 'Set'.
node_modules/angular2/src/core/facade/collection.d.ts(95,22): Error TS2304: Cannot find name 'Set'.
node_modules/angular2/src/core/facade/collection.d.ts(96,25): Error TS2304: Cannot find name 'Set'.
node_modules/angular2/src/core/facade/lang.d.ts(1,22): Error TS2304: Cannot find name 'BrowserNodeGlobal'.
node_modules/angular2/src/core/facade/lang.d.ts(33,59): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/facade/promise.d.ts(1,10): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(3,14): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(8,32): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(9,38): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(10,35): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(10,93): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(11,34): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(12,32): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(12,149): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/facade/promise.d.ts(13,43): Error TS2304: Cannot find name 'Promise'.
node_modules/angular2/src/core/linker/element_injector.d.ts(72,32): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/element_injector.d.ts(74,17): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/element_injector.d.ts(78,184): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/element_injector.d.ts(83,182): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/element_injector.d.ts(107,37): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/proto_view_factory.d.ts(27,146): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/view.d.ts(52,144): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/view.d.ts(76,79): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/view.d.ts(77,73): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/view.d.ts(94,31): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/view.d.ts(97,18): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/view.d.ts(100,24): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/view.d.ts(103,142): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/linker/view.d.ts(104,160): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/render/api.d.ts(281,74): Error TS2304: Cannot find name 'Map'.
node_modules/angular2/src/core/zone/ng_zone.d.ts(1,37): Error TS2304: Cannot find name 'Zone'.
这是代码:
import 'reflect-metadata';
import {bootstrap,Component,CORE_DIRECTIVES,FORM_DIRECTIVES} from 'angular2/core';
@Component({
selector: 'my-app',template: '<input type="text" [(ng-model)]="title" /><h1>{{title}}</h1>',directives: [ CORE_DIRECTIVES ]
})
class AppComponent {
title :string;
constructor() {
this.title = 'hello angular 2';
}
}
bootstrap(AppComponent);
angularjs – 错误:找不到模块’@ ionic/app-scripts’
今天关于错误:找不到模块“ @ ionic / app-scripts”和错误找不到指定的模块的介绍到此结束,谢谢您的阅读,有关./components/Avatar.tsx 错误:找不到模块“@babel/preset-stage-0”、angular – Ionic 2 – 运行时错误找不到模块“.”、Angular 和 Typescript:找不到名称 - 错误:找不到名称、angularjs – 错误:找不到模块’@ ionic/app-scripts’等更多相关知识的信息可以在本站进行查询。
本文标签: